diff --git a/README.md b/README.md
index 48d08ef152c..c881e882abf 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# 
-Version 4.15.0 / August 17, 2025
+Version 4.16.0 / August 29, 2025
:heart: [Sponsor](https://github.com/sponsors/rbri)
@@ -61,7 +61,7 @@ Add to your `pom.xml`:
org.htmlunithtmlunit
- 4.15.0
+ 4.16.0
```
@@ -70,7 +70,7 @@ Add to your `pom.xml`:
Add to your `build.gradle`:
```groovy
-implementation group: 'org.htmlunit', name: 'htmlunit', version: '4.15.0'
+implementation group: 'org.htmlunit', name: 'htmlunit', version: '4.16.0'
```
## Getting Started
@@ -220,7 +220,7 @@ Add the snapshot repository and dependency to your `pom.xml`:
org.htmlunithtmlunit
- 4.15.0-SNAPSHOT
+ 4.17.0-SNAPSHOT
@@ -239,7 +239,7 @@ repositories {
}
// ...
dependencies {
- implementation group: 'org.htmlunit', name: 'htmlunit', version: '4.15.0-SNAPSHOT'
+ implementation group: 'org.htmlunit', name: 'htmlunit', version: '4.17.0-SNAPSHOT'
// ...
}
```
diff --git a/checkstyle_suppressions.xml b/checkstyle_suppressions.xml
index 4f6e265723d..392ee5705aa 100644
--- a/checkstyle_suppressions.xml
+++ b/checkstyle_suppressions.xml
@@ -6,6 +6,7 @@
+
diff --git a/pmd-ruleset.xml b/pmd-ruleset.xml
index 0227746ff69..08472ee42f3 100644
--- a/pmd-ruleset.xml
+++ b/pmd-ruleset.xml
@@ -7,6 +7,7 @@
HtmlUnit rules.*/src/test/resources/.*
+ .*/src/main/java/org/htmlunit/util/brotli/.*
diff --git a/pom.xml b/pom.xml
index 1cbf8b0991e..336f2488e1f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
org.htmlunithtmlunit
- 4.15.0
+ 4.16.0jarHtmlUnit
@@ -27,23 +27,23 @@
88
- 4.15.0
- 4.15.0
- 4.15.0
- 4.15.0
- 4.15.0
- 4.15.0
+ 4.16.0
+ 4.16.0
+ 4.16.0
+ 4.16.0
+ 4.16.0
+ 4.16.04.5.143.18.02.20.01.3.5
- 0.1.2
+
- 4.34.0
- 4.34.0
- selenium-devtools-v138
+ 4.35.0
+ 4.35.0
+ selenium-devtools-v1395.13.4
@@ -59,8 +59,8 @@
1.5.6
- 10.26.1
- 4.9.3
+ 11.0.0
+ 4.9.47.16.01.4.110.0.4
@@ -69,7 +69,7 @@
0.8.03.6.03.27.0
- 4.9.3.2
+ 4.9.4.03.2.83.6.12.12.1
@@ -1372,11 +1372,11 @@
commons-logging${commons-logging.version}
-
+
diff --git a/spotbugs-exclude.xml b/spotbugs-exclude.xml
index 6fc5a39a6ca..70cc08ccb19 100644
--- a/spotbugs-exclude.xml
+++ b/spotbugs-exclude.xml
@@ -7,4 +7,9 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c0bf4ec15fb..63493bdd265 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -7,6 +7,55 @@
+
+
+ core-js: infer function names at runtime for computed properties
+
+
+ core-js: Several fixes for calling bind() in the interpreter (regression from 4.14.0)
+
+
+ core-js: ES2025 ArrayBuffer transfer(), and transferToFixedLength() implemented
+
+
+ core-js: internal optimizations to make 'undefined' lookup faster
+
+
+ core-js: ES2025 Set methods intersection(), union(), difference(), symmetricDifference(), isSubsetOf(),
+ isSupersetOf(), and isDisjointFrom() implemented
+
+
+ core-js: make Object.assign copy over Symbol properties
+
+
+ core-js: some methods should not have a prototype property
+
+
+ core-js: ES2025 Promise.try implemented
+
+
+ core-js: spread for object literals implemented
+
+
+ neko: do not check for bom headers on compressed streams
+
+
+ WebClient waitForBackgroundJavaScript(long), waitForBackgroundJavaScriptStartingBefore(long), and
+ waitForBackgroundJavaScriptStartingBefore(long, long) no longer marked as experimental.
+
+
+ Use our own 'fork' of the current brotli source code. This makes some fixes available that are
+ done in the code base but not release so far.
+
+
+ Use our own StringUtils at more places to be comptible with older commons lang versions.
+
+
+ Handling of CData sections in XHTML documents improved/fixed.
+
+
+
+
WebAssert messages reviewed and improved.
@@ -14002,7 +14051,7 @@
Upgraded commons-collections to version 3.1
- Upgraded commons-beanutil to version 1.7.0
+ Upgraded commons-beanutils to version 1.7.0
Upgraded commons-httpclient to version 2.0.1
diff --git a/src/main/java/org/htmlunit/DefaultPageCreator.java b/src/main/java/org/htmlunit/DefaultPageCreator.java
index ea3bcc5f3e2..fcf918e29db 100644
--- a/src/main/java/org/htmlunit/DefaultPageCreator.java
+++ b/src/main/java/org/htmlunit/DefaultPageCreator.java
@@ -21,7 +21,6 @@
import java.util.Locale;
import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
import org.htmlunit.html.DomElement;
import org.htmlunit.html.Html;
import org.htmlunit.html.HtmlPage;
@@ -29,6 +28,7 @@
import org.htmlunit.html.parser.HTMLParser;
import org.htmlunit.html.parser.neko.HtmlUnitNekoHtmlParser;
import org.htmlunit.util.MimeType;
+import org.htmlunit.util.StringUtils;
import org.htmlunit.xml.XmlPage;
/**
@@ -156,7 +156,7 @@ public static PageType determinePageType(final String contentType) {
*/
public static PageType determinePageType(final WebResponse webResponse) throws IOException {
final String contentType = webResponse.getContentType();
- if (!StringUtils.isEmpty(contentType)) {
+ if (!StringUtils.isEmptyOrNull(contentType)) {
return determinePageType(contentType);
}
diff --git a/src/main/java/org/htmlunit/WebClient.java b/src/main/java/org/htmlunit/WebClient.java
index 321f22a3e78..dea58210165 100644
--- a/src/main/java/org/htmlunit/WebClient.java
+++ b/src/main/java/org/htmlunit/WebClient.java
@@ -54,7 +54,6 @@
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.NoHttpResponseException;
@@ -98,6 +97,7 @@
import org.htmlunit.util.HeaderUtils;
import org.htmlunit.util.MimeType;
import org.htmlunit.util.NameValuePair;
+import org.htmlunit.util.StringUtils;
import org.htmlunit.util.UrlUtils;
import org.htmlunit.websocket.JettyWebSocketAdapter.JettyWebSocketAdapterFactory;
import org.htmlunit.websocket.WebSocketAdapter;
@@ -624,13 +624,13 @@ public Page loadWebResponseInto(final WebResponse webResponse, final WebWindow w
&& (forceAttachmentWithFilename != null || attachmentHandler_.isAttachment(webResponse))) {
// check content disposition header for nothing provided
- if (StringUtils.isEmpty(forceAttachmentWithFilename)) {
+ if (StringUtils.isEmptyOrNull(forceAttachmentWithFilename)) {
final String disp = webResponse.getResponseHeaderValue(HttpHeader.CONTENT_DISPOSITION);
forceAttachmentWithFilename = Attachment.getSuggestedFilename(disp);
}
if (attachmentHandler_.handleAttachment(webResponse,
- StringUtils.isEmpty(forceAttachmentWithFilename) ? null : forceAttachmentWithFilename)) {
+ StringUtils.isEmptyOrNull(forceAttachmentWithFilename) ? null : forceAttachmentWithFilename)) {
// the handling is done by the attachment handler;
// do not open a new window
return webWindow.getEnclosedPage();
@@ -639,7 +639,8 @@ public Page loadWebResponseInto(final WebResponse webResponse, final WebWindow w
final WebWindow w = openWindow(null, null, webWindow);
final Page page = pageCreator_.createPage(webResponse, w);
attachmentHandler_.handleAttachment(page,
- StringUtils.isEmpty(forceAttachmentWithFilename) ? null : forceAttachmentWithFilename);
+ StringUtils.isEmptyOrNull(forceAttachmentWithFilename)
+ ? null : forceAttachmentWithFilename);
return page;
}
@@ -1383,8 +1384,9 @@ private static WebResponse makeWebResponseForAboutUrl(final WebRequest webReques
return new StringWebResponse("", UrlUtils.URL_ABOUT_BLANK);
}
- final String urlWithoutQuery = StringUtils.substringBefore(urlString, "?");
- if (!"blank".equalsIgnoreCase(StringUtils.substringAfter(urlWithoutQuery, UrlUtils.ABOUT_SCHEME))) {
+ final String urlWithoutQuery = org.apache.commons.lang3.StringUtils.substringBefore(urlString, "?");
+ if (!"blank".equalsIgnoreCase(org.apache.commons.lang3.StringUtils
+ .substringAfter(urlWithoutQuery, UrlUtils.ABOUT_SCHEME))) {
throw new MalformedURLException(url + " is not supported, only about:blank is supported at the moment.");
}
return new StringWebResponse("", url);
@@ -1423,7 +1425,7 @@ private WebResponse makeWebResponseForFileUrl(final WebRequest webRequest) throw
compiledHeaders.add(new NameValuePair(HttpHeader.CONTENT_TYPE, MimeType.TEXT_HTML));
final WebResponseData responseData =
new WebResponseData(
- org.htmlunit.util.StringUtils
+ StringUtils
.toByteArray("File: " + file.getAbsolutePath(), UTF_8),
404, "Not Found", compiledHeaders);
return new WebResponse(responseData, webRequest, 0);
@@ -1451,13 +1453,13 @@ private WebResponse makeWebResponseForBlobUrl(final WebRequest webRequest) {
final List headers = new ArrayList<>();
final String type = fileOrBlob.getType();
- if (!StringUtils.isEmpty(type)) {
+ if (!StringUtils.isEmptyOrNull(type)) {
headers.add(new NameValuePair(HttpHeader.CONTENT_TYPE, fileOrBlob.getType()));
}
if (fileOrBlob instanceof org.htmlunit.javascript.host.file.File) {
final org.htmlunit.javascript.host.file.File file = (org.htmlunit.javascript.host.file.File) fileOrBlob;
final String fileName = file.getName();
- if (!StringUtils.isEmpty(fileName)) {
+ if (!StringUtils.isEmptyOrNull(fileName)) {
// https://datatracker.ietf.org/doc/html/rfc6266#autoid-10
headers.add(new NameValuePair(HttpHeader.CONTENT_DISPOSITION, "inline; filename=\"" + fileName + "\""));
}
@@ -2411,24 +2413,46 @@ public void reset() {
}
/**
- *
Experimental API: May be changed in next release
- * and may not yet work perfectly!
- *
- *
This method blocks until all background JavaScript tasks have finished executing. Background
- * JavaScript tasks are JavaScript tasks scheduled for execution via window.setTimeout,
- * window.setInterval or asynchronous XMLHttpRequest.
- *
- *
If a job is scheduled to begin executing after (now + timeoutMillis), this method will
- * wait for timeoutMillis milliseconds and then return a value greater than 0. This
- * method will never block longer than timeoutMillis milliseconds.
- *
- *
Use this method instead of {@link #waitForBackgroundJavaScriptStartingBefore(long)} if you
- * don't know when your background JavaScript is supposed to start executing, but you're fairly sure
- * that you know how long it should take to finish executing.
- *
- * @param timeoutMillis the maximum amount of time to wait (in milliseconds)
- * @return the number of background JavaScript jobs still executing or waiting to be executed when this
- * method returns; will be 0 if there are no jobs left to execute
+ *
Blocks until all background JavaScript tasks have finished executing or until the specified
+ * timeout is reached, whichever occurs first. Background JavaScript tasks include:
+ *
+ *
JavaScript scheduled via window.setTimeout()
+ *
JavaScript scheduled via window.setInterval()
+ *
Asynchronous XMLHttpRequest operations
+ *
Other asynchronous JavaScript operations across all windows managed by this WebClient
+ *
+ *
+ *
Timeout Behavior: If background tasks are scheduled to execute after
+ * (now + timeoutMillis), this method will wait for the full timeout duration
+ * and then return the number of remaining jobs. The method guarantees it will never block
+ * longer than the specified timeout.
+ *
+ *
Use Case: Use this method when you don't know the exact timing of when
+ * background JavaScript will start, but you have a reasonable estimate of how long all
+ * tasks should take to complete. For scenarios where you know when tasks should start
+ * executing, consider using {@link #waitForBackgroundJavaScriptStartingBefore(long)} instead.
+ *
+ *
Thread Safety: This method is thread-safe and handles concurrent
+ * modifications to the internal job manager list gracefully.
+ *
+ *
Example Usage:
+ *
+ * // Wait up to 5 seconds for all background JavaScript to complete
+ * int remainingJobs = webClient.waitForBackgroundJavaScript(5000);
+ * if (remainingJobs == 0) {
+ * log("All background JavaScript completed");
+ * } else {
+ * log("Timeout reached, " + remainingJobs + " jobs still pending");
+ * }
+ *
+ *
+ * @param timeoutMillis the maximum amount of time to wait in milliseconds; must be positive
+ * @return the number of background JavaScript jobs still executing or waiting to be executed
+ * when this method returns; returns 0 if all jobs completed successfully
+ * within the timeout period
+ * @throws IllegalArgumentException if timeoutMillis is negative
+ * @see #waitForBackgroundJavaScriptStartingBefore(long)
+ * @see #waitForBackgroundJavaScriptStartingBefore(long, long)
*/
public int waitForBackgroundJavaScript(final long timeoutMillis) {
int count = 0;
@@ -2461,58 +2485,123 @@ public int waitForBackgroundJavaScript(final long timeoutMillis) {
}
/**
- *
Experimental API: May be changed in next release
- * and may not yet work perfectly!
- *
- *
This method blocks until all background JavaScript tasks scheduled to start executing before
- * (now + delayMillis) have finished executing. Background JavaScript tasks are JavaScript
- * tasks scheduled for execution via window.setTimeout, window.setInterval or
- * asynchronous XMLHttpRequest.
- *
- *
If there is no background JavaScript task currently executing, and there is no background JavaScript
- * task scheduled to start executing within the specified time, this method returns immediately -- even
- * if there are tasks scheduled to be executed after (now + delayMillis).
- *
- *
Note that the total time spent executing a background JavaScript task is never known ahead of
- * time, so this method makes no guarantees as to how long it will block.
- *
- *
Use this method instead of {@link #waitForBackgroundJavaScript(long)} if you know roughly when
- * your background JavaScript is supposed to start executing, but you're not necessarily sure how long
- * it will take to execute.
- *
- * @param delayMillis the delay which determines the background tasks to wait for (in milliseconds)
- * @return the number of background JavaScript jobs still executing or waiting to be executed when this
- * method returns; will be 0 if there are no jobs left to execute
+ *
Blocks until all background JavaScript tasks scheduled to start executing before
+ * (now + delayMillis) have finished executing. Background JavaScript tasks include:
+ *
+ *
JavaScript scheduled via window.setTimeout()
+ *
JavaScript scheduled via window.setInterval()
+ *
Asynchronous XMLHttpRequest operations
+ *
Other asynchronous JavaScript operations across all windows managed by this WebClient
+ *
+ *
+ *
Method Behavior:
+ *
+ *
If no background JavaScript tasks are currently executing and none are scheduled
+ * to start within delayMillis, this method returns immediately
+ *
Tasks scheduled to execute after (now + delayMillis) are ignored
+ * and do not affect the waiting behavior
+ *
The method waits for tasks to complete execution, not just to start
+ *
This method waits indefinitely for qualifying tasks to complete (no timeout)
+ *
+ *
+ *
Use Case: This method is ideal when you know approximately when
+ * background JavaScript should start executing but are uncertain about execution duration.
+ * Use this when you don't need a timeout and want to ensure all relevant tasks complete.
+ * For scenarios where you need to wait for all background tasks regardless of timing,
+ * use {@link #waitForBackgroundJavaScript(long)} instead. For timeout control, use
+ * {@link #waitForBackgroundJavaScriptStartingBefore(long, long)} instead.
+ *
+ *
Thread Safety: This method is thread-safe and handles concurrent
+ * modifications to the internal job manager list gracefully.
+ *
+ *
Example Usage:
+ *
+ * // Wait indefinitely for JavaScript tasks starting within 1 second
+ * int remainingJobs = webClient.waitForBackgroundJavaScriptStartingBefore(1000);
+ * if (remainingJobs == 0) {
+ * log("All relevant background JavaScript completed");
+ * } else {
+ * log("Some tasks may still be pending: " + remainingJobs + " jobs");
+ * }
+ *
+ * // Common pattern: wait for tasks that should start soon
+ * // (useful after triggering an action that schedules JavaScript)
+ * webClient.waitForBackgroundJavaScriptStartingBefore(500);
+ *
+ *
+ * @param delayMillis the delay which determines the background tasks to wait for (in milliseconds);
+ * must be non-negative
+ * @return the number of background JavaScript jobs still executing or waiting to be executed
+ * when this method returns; returns 0 if all qualifying jobs completed
+ * successfully
+ * @see #waitForBackgroundJavaScript(long)
+ * @see #waitForBackgroundJavaScriptStartingBefore(long, long)
*/
public int waitForBackgroundJavaScriptStartingBefore(final long delayMillis) {
return waitForBackgroundJavaScriptStartingBefore(delayMillis, -1);
}
/**
- *
Experimental API: May be changed in next release
- * and may not yet work perfectly!
- *
- *
This method blocks until all background JavaScript tasks scheduled to start executing before
- * (now + delayMillis) have finished executing. Background JavaScript tasks are JavaScript
- * tasks scheduled for execution via window.setTimeout, window.setInterval or
- * asynchronous XMLHttpRequest.
- *
- *
If there is no background JavaScript task currently executing, and there is no background JavaScript
- * task scheduled to start executing within the specified time, this method returns immediately -- even
- * if there are tasks scheduled to be executed after (now + delayMillis).
- *
- *
Note that the total time spent executing a background JavaScript task is never known ahead of
- * time, so this method makes no guarantees as to how long it will block.
- *
- *
Use this method instead of {@link #waitForBackgroundJavaScript(long)} if you know roughly when
- * your background JavaScript is supposed to start executing, but you're not necessarily sure how long
- * it will take to execute.
- *
- * @param delayMillis the delay which determines the background tasks to wait for (in milliseconds)
- * @param timeoutMillis the maximum amount of time to wait (in milliseconds); this has to be larger than
- * the delayMillis parameter, otherwise the timeout is ignored
- * @return the number of background JavaScript jobs still executing or waiting to be executed when this
- * method returns; will be 0 if there are no jobs left to execute
+ *
Blocks until all background JavaScript tasks scheduled to start executing before
+ * (now + delayMillis) have finished executing, or until the specified timeout
+ * is reached, whichever occurs first. Background JavaScript tasks include:
+ *
+ *
JavaScript scheduled via window.setTimeout()
+ *
JavaScript scheduled via window.setInterval()
+ *
Asynchronous XMLHttpRequest operations
+ *
Other asynchronous JavaScript operations across all windows managed by this WebClient
+ *
+ *
+ *
Method Behavior:
+ *
+ *
If no background JavaScript tasks are currently executing and none are scheduled
+ * to start within delayMillis, this method returns immediately
+ *
Tasks scheduled to execute after (now + delayMillis) are ignored
+ * and do not affect the waiting behavior
+ *
The method waits for tasks to complete execution, not just to start
+ *
+ *
+ *
Timeout Behavior:
+ *
+ *
If timeoutMillis is negative or less than delayMillis,
+ * the timeout is ignored and the method waits indefinitely
+ *
When a valid timeout is specified, the method will never block longer than
+ * timeoutMillis milliseconds
+ *
The timeout applies to the total waiting time, not per task
+ *
+ *
+ *
Use Case: This method is ideal when you know approximately when
+ * background JavaScript should start executing but are uncertain about execution duration.
+ * For scenarios where you need to wait for all background tasks regardless of timing,
+ * use {@link #waitForBackgroundJavaScript(long)} instead.
+ *
+ *
Thread Safety: This method is thread-safe and handles concurrent
+ * modifications to the internal job manager list gracefully.
+ *
+ *
Example Usage:
+ *
+ * // Wait for JavaScript tasks starting within 1 second, with 10 second max timeout
+ * int remainingJobs = webClient.waitForBackgroundJavaScriptStartingBefore(1000, 10000);
+ * if (remainingJobs == 0) {
+ * log("All relevant background JavaScript completed");
+ * } else {
+ * log("Timeout reached or tasks still pending: " + remainingJobs + " jobs");
+ * }
+ *
+ * // Wait indefinitely for tasks starting within 500ms (timeout ignored)
+ * webClient.waitForBackgroundJavaScriptStartingBefore(500, 100); // timeout < delay
+ *
+ *
+ * @param delayMillis the delay which determines the background tasks to wait for (in milliseconds);
+ * must be non-negative
+ * @param timeoutMillis the maximum amount of time to wait (in milliseconds); if negative or
+ * less than delayMillis, the timeout is ignored and the method
+ * waits indefinitely for qualifying tasks to complete
+ * @return the number of background JavaScript jobs still executing or waiting to be executed
+ * when this method returns; returns 0 if all qualifying jobs completed
+ * successfully within the specified constraints
+ * @see #waitForBackgroundJavaScript(long)
+ * @see #waitForBackgroundJavaScriptStartingBefore(long)
*/
public int waitForBackgroundJavaScriptStartingBefore(final long delayMillis, final long timeoutMillis) {
int count = 0;
diff --git a/src/main/java/org/htmlunit/WebResponse.java b/src/main/java/org/htmlunit/WebResponse.java
index f7f93cdc7c5..e890e479d66 100644
--- a/src/main/java/org/htmlunit/WebResponse.java
+++ b/src/main/java/org/htmlunit/WebResponse.java
@@ -28,13 +28,13 @@
import org.apache.commons.io.ByteOrderMark;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.input.BOMInputStream;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.htmlunit.http.HttpStatus;
import org.htmlunit.util.EncodingSniffer;
import org.htmlunit.util.MimeType;
import org.htmlunit.util.NameValuePair;
+import org.htmlunit.util.StringUtils;
/**
* A response from a web server.
diff --git a/src/main/java/org/htmlunit/WebResponseData.java b/src/main/java/org/htmlunit/WebResponseData.java
index 74196109ea6..5a1f7916017 100644
--- a/src/main/java/org/htmlunit/WebResponseData.java
+++ b/src/main/java/org/htmlunit/WebResponseData.java
@@ -29,12 +29,12 @@
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.input.BOMInputStream;
import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.Strings;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.brotli.dec.BrotliInputStream;
import org.htmlunit.util.MimeType;
import org.htmlunit.util.NameValuePair;
+import org.htmlunit.util.StringUtils;
+import org.htmlunit.util.brotli.BrotliInputStream;
/**
* Simple data object to simplify WebResponse creation.
@@ -101,7 +101,7 @@ private InputStream getStream(final ByteOrderMark... bomHeaders) throws IOExcept
final List headers = getResponseHeaders();
final String encoding = getHeader(headers, "content-encoding");
if (encoding != null) {
- boolean isGzip = Strings.CI.contains(encoding, "gzip") && !"no-gzip".equals(encoding);
+ boolean isGzip = StringUtils.containsIgnoreCase(encoding, "gzip") && !"no-gzip".equals(encoding);
if ("gzip-only-text/html".equals(encoding)) {
isGzip = MimeType.TEXT_HTML.equals(getHeader(headers, "content-type"));
}
@@ -148,7 +148,7 @@ private InputStream getStream(final ByteOrderMark... bomHeaders) throws IOExcept
return stream;
}
- if (Strings.CI.contains(encoding, "deflate")) {
+ if (StringUtils.containsIgnoreCase(encoding, "deflate")) {
boolean zlibHeader = false;
if (stream.markSupported()) { // should be always the case as the content is in a byte[] or in a file
stream.mark(2);
diff --git a/src/main/java/org/htmlunit/attachment/DownloadingAttachmentHandler.java b/src/main/java/org/htmlunit/attachment/DownloadingAttachmentHandler.java
index 92d80ffe9ec..7da2c8549d3 100644
--- a/src/main/java/org/htmlunit/attachment/DownloadingAttachmentHandler.java
+++ b/src/main/java/org/htmlunit/attachment/DownloadingAttachmentHandler.java
@@ -22,11 +22,11 @@
import java.nio.file.Paths;
import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.htmlunit.Page;
import org.htmlunit.WebResponse;
+import org.htmlunit.util.StringUtils;
/**
* Implementation of an {@link AttachmentHandler} that mimics how browsers handle attachments, specifically
@@ -98,12 +98,12 @@ public void handleAttachment(final Page page, final String attachmentFilename) {
private Path determineDestionationFile(final Page page, final String attachmentFilename) {
String fileName = attachmentFilename;
- if (StringUtils.isAllBlank(fileName)) {
+ if (StringUtils.isBlank(fileName)) {
final String file = page.getWebResponse().getWebRequest().getUrl().getFile();
fileName = file.substring(file.lastIndexOf('/') + 1);
}
- if (StringUtils.isAllBlank(fileName)) {
+ if (StringUtils.isBlank(fileName)) {
fileName = "download";
}
diff --git a/src/main/java/org/htmlunit/css/AbstractCssStyleDeclaration.java b/src/main/java/org/htmlunit/css/AbstractCssStyleDeclaration.java
index 80fc46355e9..83529e6bfba 100644
--- a/src/main/java/org/htmlunit/css/AbstractCssStyleDeclaration.java
+++ b/src/main/java/org/htmlunit/css/AbstractCssStyleDeclaration.java
@@ -265,9 +265,9 @@ public boolean isComputed() {
*/
public String getBackgroundAttachment() {
String value = getStyleAttribute(Definition.BACKGROUND_ATTACHMENT, false);
- if (org.apache.commons.lang3.StringUtils.isBlank(value)) {
+ if (StringUtils.isBlank(value)) {
final String bg = getStyleAttribute(Definition.BACKGROUND, true);
- if (org.apache.commons.lang3.StringUtils.isNotBlank(bg)) {
+ if (StringUtils.isNotBlank(bg)) {
value = findAttachment(bg);
if (value == null) {
if (hasFeature(CSS_BACKGROUND_INITIAL) && !isComputed()) {
@@ -289,9 +289,9 @@ public String getBackgroundAttachment() {
*/
public String getBackgroundColor() {
String value = getStyleAttribute(Definition.BACKGROUND_COLOR, false);
- if (org.apache.commons.lang3.StringUtils.isBlank(value)) {
+ if (StringUtils.isBlank(value)) {
final String bg = getStyleAttribute(Definition.BACKGROUND, false);
- if (org.apache.commons.lang3.StringUtils.isBlank(bg)) {
+ if (StringUtils.isBlank(bg)) {
return "";
}
value = findColor(bg);
@@ -309,7 +309,7 @@ public String getBackgroundColor() {
}
return value;
}
- if (org.apache.commons.lang3.StringUtils.isBlank(value)) {
+ if (StringUtils.isBlank(value)) {
return "";
}
return value;
@@ -321,9 +321,9 @@ public String getBackgroundColor() {
*/
public String getBackgroundImage() {
String value = getStyleAttribute(Definition.BACKGROUND_IMAGE, false);
- if (org.apache.commons.lang3.StringUtils.isBlank(value)) {
+ if (StringUtils.isBlank(value)) {
final String bg = getStyleAttribute(Definition.BACKGROUND, false);
- if (org.apache.commons.lang3.StringUtils.isNotBlank(bg)) {
+ if (StringUtils.isNotBlank(bg)) {
value = findImageUrl(bg);
final boolean backgroundInitial = hasFeature(CSS_BACKGROUND_INITIAL);
if (value == null) {
@@ -357,12 +357,12 @@ public String getBackgroundPosition() {
if (value == null) {
return null;
}
- if (org.apache.commons.lang3.StringUtils.isBlank(value)) {
+ if (StringUtils.isBlank(value)) {
final String bg = getStyleAttribute(Definition.BACKGROUND, false);
if (bg == null) {
return null;
}
- if (org.apache.commons.lang3.StringUtils.isNotBlank(bg)) {
+ if (StringUtils.isNotBlank(bg)) {
value = findPosition(bg);
final boolean isInitial = hasFeature(CSS_BACKGROUND_INITIAL);
if (value == null) {
@@ -419,9 +419,9 @@ public String getBackgroundPosition() {
*/
public String getBackgroundRepeat() {
String value = getStyleAttribute(Definition.BACKGROUND_REPEAT, false);
- if (org.apache.commons.lang3.StringUtils.isBlank(value)) {
+ if (StringUtils.isBlank(value)) {
final String bg = getStyleAttribute(Definition.BACKGROUND, false);
- if (org.apache.commons.lang3.StringUtils.isNotBlank(bg)) {
+ if (StringUtils.isNotBlank(bg)) {
value = findRepeat(bg);
if (value == null) {
if (hasFeature(CSS_BACKGROUND_INITIAL) && !isComputed()) {
@@ -545,7 +545,7 @@ private String getBorderWidth(final Definition borderSideWidth, final Definition
value = findBorderWidth(getStyleAttribute(borderSide, false));
if (value == null) {
final String borderWidth = getStyleAttribute(Definition.BORDER_WIDTH, false);
- if (!org.apache.commons.lang3.StringUtils.isEmpty(borderWidth)) {
+ if (!StringUtils.isEmptyOrNull(borderWidth)) {
final String[] values = StringUtils.splitAtJavaWhitespace(borderWidth);
int index = values.length;
if (borderSideWidth.name().contains("TOP")) {
diff --git a/src/main/java/org/htmlunit/css/ComputedCssStyleDeclaration.java b/src/main/java/org/htmlunit/css/ComputedCssStyleDeclaration.java
index 702b704a269..d46edaf43dd 100644
--- a/src/main/java/org/htmlunit/css/ComputedCssStyleDeclaration.java
+++ b/src/main/java/org/htmlunit/css/ComputedCssStyleDeclaration.java
@@ -43,7 +43,6 @@
import java.util.SortedMap;
import java.util.TreeMap;
-import org.apache.commons.lang3.StringUtils;
import org.htmlunit.BrowserVersion;
import org.htmlunit.BrowserVersionFeatures;
import org.htmlunit.Page;
@@ -148,6 +147,7 @@
import org.htmlunit.html.HtmlVariable;
import org.htmlunit.html.HtmlWordBreak;
import org.htmlunit.platform.Platform;
+import org.htmlunit.util.StringUtils;
/**
* An object for a CSSStyleDeclaration, which is computed.
@@ -274,7 +274,7 @@ public String getStyleAttribute(final String name) {
final String value = element.getValue();
if (!"content".equals(name)
&& !value.contains("url")) {
- return org.htmlunit.util.StringUtils.toRootLowerCase(value);
+ return StringUtils.toRootLowerCase(value);
}
return value;
}
@@ -411,7 +411,7 @@ public String getWidth() {
@Override
public String get(final ComputedCssStyleDeclaration style) {
final String value = style.getStyleAttribute(Definition.WIDTH, true);
- if (StringUtils.isEmpty(value)) {
+ if (StringUtils.isEmptyOrNull(value)) {
final String position = getStyleAttribute(Definition.POSITION, true);
if (ABSOLUTE.equals(position) || FIXED.equals(position)) {
final String content = domElem.getVisibleText();
@@ -534,7 +534,7 @@ public String getBackgroundColor() {
}
final String value = super.getBackgroundColor();
- if (StringUtils.isEmpty(value)) {
+ if (StringUtils.isEmptyOrNull(value)) {
return Definition.BACKGROUND_COLOR.getDefaultComputedValue(getBrowserVersion());
}
return CssColors.toRGBColor(value);
@@ -583,7 +583,7 @@ public String getBlockSize() {
@Override
public String get(final ComputedCssStyleDeclaration style) {
final String value = style.getStyleAttribute(Definition.HEIGHT, true);
- if (StringUtils.isEmpty(value)) {
+ if (StringUtils.isEmptyOrNull(value)) {
final String content = domElem.getVisibleText();
// do this only for small content
// at least for empty div's this is more correct
@@ -737,7 +737,7 @@ public String getDisplay() {
// don't use defaultIfEmpty for performance
// (no need to calculate the default if not empty)
final String value = getStyleAttribute(Definition.DISPLAY.getAttributeName());
- if (StringUtils.isEmpty(value)) {
+ if (StringUtils.isEmptyOrNull(value)) {
if (domElem instanceof HtmlElement) {
return ((HtmlElement) domElem).getDefaultStyleDisplay().value();
}
@@ -1570,7 +1570,8 @@ private int getCalculatedWidth() {
final DomNode parent = element.getParentNode();
// width is ignored for inline elements
- if ((INLINE.equals(display) || StringUtils.isEmpty(styleWidth)) && parent instanceof HtmlElement) {
+ if ((INLINE.equals(display) || StringUtils.isEmptyOrNull(styleWidth))
+ && parent instanceof HtmlElement) {
// hack: TODO find a way to specify default values for different tags
if (element instanceof HtmlCanvas) {
return 300;
@@ -1962,11 +1963,11 @@ else if (element instanceof HtmlHeading6) {
defaultHeight *= lineCount;
}
else {
- if (element instanceof HtmlSpan && StringUtils.isEmpty(content)) {
+ if (element instanceof HtmlSpan && StringUtils.isEmptyOrNull(content)) {
defaultHeight = 0;
}
else {
- defaultHeight *= StringUtils.countMatches(content, '\n') + 1;
+ defaultHeight *= org.apache.commons.lang3.StringUtils.countMatches(content, '\n') + 1;
}
}
@@ -2082,11 +2083,11 @@ private boolean isScrollable(final DomElement element, final boolean horizontal,
String overflow;
if (horizontal) {
overflow = getStyleAttribute(Definition.OVERFLOW_X_, false);
- if (StringUtils.isEmpty(overflow)) {
+ if (StringUtils.isEmptyOrNull(overflow)) {
overflow = getStyleAttribute(Definition.OVERFLOW_X, false);
}
// fall back to default
- if (StringUtils.isEmpty(overflow)) {
+ if (StringUtils.isEmptyOrNull(overflow)) {
overflow = getStyleAttribute(Definition.OVERFLOW, true);
}
scrollable = (element instanceof HtmlBody || SCROLL.equals(overflow) || AUTO.equals(overflow))
@@ -2094,11 +2095,11 @@ private boolean isScrollable(final DomElement element, final boolean horizontal,
}
else {
overflow = getStyleAttribute(Definition.OVERFLOW_Y_, false);
- if (StringUtils.isEmpty(overflow)) {
+ if (StringUtils.isEmptyOrNull(overflow)) {
overflow = getStyleAttribute(Definition.OVERFLOW_Y, false);
}
// fall back to default
- if (StringUtils.isEmpty(overflow)) {
+ if (StringUtils.isEmptyOrNull(overflow)) {
overflow = getStyleAttribute(Definition.OVERFLOW, true);
}
diff --git a/src/main/java/org/htmlunit/css/CssStyleSheet.java b/src/main/java/org/htmlunit/css/CssStyleSheet.java
index fd3f7f797ee..10b61180670 100644
--- a/src/main/java/org/htmlunit/css/CssStyleSheet.java
+++ b/src/main/java/org/htmlunit/css/CssStyleSheet.java
@@ -38,8 +38,6 @@
import java.util.regex.Pattern;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.Strings;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -102,6 +100,7 @@
import org.htmlunit.javascript.host.css.MediaList;
import org.htmlunit.javascript.host.dom.Document;
import org.htmlunit.util.MimeType;
+import org.htmlunit.util.StringUtils;
import org.htmlunit.util.UrlUtils;
/**
@@ -353,7 +352,7 @@ public static CssStyleSheet loadStylesheet(final HtmlElement element, final Html
final CssStyleSheet sheet;
final String contentType = response.getContentType();
- if (StringUtils.isEmpty(contentType) || MimeType.TEXT_CSS.equals(contentType)) {
+ if (StringUtils.isEmptyOrNull(contentType) || MimeType.TEXT_CSS.equals(contentType)) {
try (InputStream in = response.getContentAsStreamWithBomIfApplicable()) {
if (in == null) {
if (LOG.isWarnEnabled()) {
@@ -563,33 +562,33 @@ static boolean selects(final BrowserVersion browserVersion,
final AttributeCondition prefixAttributeCondition = (AttributeCondition) condition;
final String prefixValue = prefixAttributeCondition.getValue();
if (prefixAttributeCondition.isCaseInSensitive()) {
- return !org.htmlunit.util.StringUtils.isEmptyString(prefixValue)
- && Strings.CI.startsWith(
+ return !StringUtils.isEmptyString(prefixValue)
+ && StringUtils.startsWithIgnoreCase(
element.getAttribute(prefixAttributeCondition.getLocalName()), prefixValue);
}
- return !org.htmlunit.util.StringUtils.isEmptyString(prefixValue)
+ return !StringUtils.isEmptyString(prefixValue)
&& element.getAttribute(prefixAttributeCondition.getLocalName()).startsWith(prefixValue);
case SUFFIX_ATTRIBUTE_CONDITION:
final AttributeCondition suffixAttributeCondition = (AttributeCondition) condition;
final String suffixValue = suffixAttributeCondition.getValue();
if (suffixAttributeCondition.isCaseInSensitive()) {
- return !org.htmlunit.util.StringUtils.isEmptyString(suffixValue)
- && Strings.CI.endsWith(
+ return !StringUtils.isEmptyString(suffixValue)
+ && StringUtils.endsWithIgnoreCase(
element.getAttribute(suffixAttributeCondition.getLocalName()), suffixValue);
}
- return !org.htmlunit.util.StringUtils.isEmptyString(suffixValue)
+ return !StringUtils.isEmptyString(suffixValue)
&& element.getAttribute(suffixAttributeCondition.getLocalName()).endsWith(suffixValue);
case SUBSTRING_ATTRIBUTE_CONDITION:
final AttributeCondition substringAttributeCondition = (AttributeCondition) condition;
final String substringValue = substringAttributeCondition.getValue();
if (substringAttributeCondition.isCaseInSensitive()) {
- return !org.htmlunit.util.StringUtils.isEmptyString(substringValue)
- && Strings.CI.contains(
+ return !StringUtils.isEmptyString(substringValue)
+ && StringUtils.containsIgnoreCase(
element.getAttribute(substringAttributeCondition.getLocalName()), substringValue);
}
- return !org.htmlunit.util.StringUtils.isEmptyString(substringValue)
+ return !StringUtils.isEmptyString(substringValue)
&& element.getAttribute(substringAttributeCondition.getLocalName()).contains(substringValue);
case BEGIN_HYPHEN_ATTRIBUTE_CONDITION:
@@ -598,8 +597,8 @@ static boolean selects(final BrowserVersion browserVersion,
final String a = element.getAttribute(beginHyphenAttributeCondition.getLocalName());
if (beginHyphenAttributeCondition.isCaseInSensitive()) {
return selectsHyphenSeparated(
- org.htmlunit.util.StringUtils.toRootLowerCase(v),
- org.htmlunit.util.StringUtils.toRootLowerCase(a));
+ StringUtils.toRootLowerCase(v),
+ StringUtils.toRootLowerCase(a));
}
return selectsHyphenSeparated(v, a);
@@ -609,8 +608,8 @@ static boolean selects(final BrowserVersion browserVersion,
final String a2 = element.getAttribute(oneOfAttributeCondition.getLocalName());
if (oneOfAttributeCondition.isCaseInSensitive()) {
return selectsOneOf(
- org.htmlunit.util.StringUtils.toRootLowerCase(v2),
- org.htmlunit.util.StringUtils.toRootLowerCase(a2));
+ StringUtils.toRootLowerCase(v2),
+ StringUtils.toRootLowerCase(a2));
}
return selectsOneOf(v2, a2);
@@ -866,8 +865,8 @@ private static boolean selectsPseudoClass(final BrowserVersion browserVersion,
case "placeholder-shown":
return element instanceof HtmlInput
- && StringUtils.isEmpty(((HtmlInput) element).getValue())
- && StringUtils.isNotEmpty(((HtmlInput) element).getPlaceholder());
+ && StringUtils.isEmptyOrNull(((HtmlInput) element).getValue())
+ && !StringUtils.isEmptyOrNull(((HtmlInput) element).getPlaceholder());
default:
if (value.startsWith("nth-child(")) {
@@ -939,7 +938,7 @@ private static boolean getNthElement(final String nth, final int index) {
int denominator = 0;
if (nIndex != -1) {
String value = nth.substring(0, nIndex).trim();
- if (org.htmlunit.util.StringUtils.equalsChar('-', value)) {
+ if (StringUtils.equalsChar('-', value)) {
denominator = -1;
}
else {
@@ -1136,7 +1135,8 @@ private static boolean isValidCondition(final Condition condition, final DomNode
}
if ("nth-child()".equals(value)) {
- final String arg = StringUtils.substringBetween(condition.getValue(), "(", ")").trim();
+ final String arg = org.apache.commons.lang3.StringUtils
+ .substringBetween(condition.getValue(), "(", ")").trim();
return "even".equalsIgnoreCase(arg) || "odd".equalsIgnoreCase(arg)
|| NTH_NUMERIC.matcher(arg).matches()
|| NTH_COMPLEX.matcher(arg).matches();
@@ -1547,7 +1547,7 @@ private List selects(
if (isActive(index.getMediaList(), element.getPage().getEnclosingWindow())) {
final String elementName = element.getLowercaseName();
- final String[] classes = org.htmlunit.util.StringUtils.splitAtJavaWhitespace(
+ final String[] classes = StringUtils.splitAtJavaWhitespace(
element.getAttributeDirect("class"));
final Iterator iter =
index.getSelectorEntriesIteratorFor(elementName, classes);
diff --git a/src/main/java/org/htmlunit/html/DomElement.java b/src/main/java/org/htmlunit/html/DomElement.java
index 6d1760742cd..a48ae44ed4e 100644
--- a/src/main/java/org/htmlunit/html/DomElement.java
+++ b/src/main/java/org/htmlunit/html/DomElement.java
@@ -213,7 +213,7 @@ public boolean hasAttribute(final String attributeName) {
* @param priority the new priority of the property; "important"or the empty string if none.
*/
public void replaceStyleAttribute(final String name, final String value, final String priority) {
- if (org.apache.commons.lang3.StringUtils.isBlank(value)) {
+ if (StringUtils.isBlank(value)) {
removeStyleAttribute(name);
return;
}
@@ -635,7 +635,7 @@ public void writeStyleToElement(final Map styleMap) {
.append(e.getValue());
final String prio = e.getPriority();
- if (org.apache.commons.lang3.StringUtils.isNotBlank(prio)) {
+ if (StringUtils.isNotBlank(prio)) {
builder.append(" !").append(prio);
}
builder.append(';');
diff --git a/src/main/java/org/htmlunit/html/DomText.java b/src/main/java/org/htmlunit/html/DomText.java
index 3af794f3539..a2969d137f1 100644
--- a/src/main/java/org/htmlunit/html/DomText.java
+++ b/src/main/java/org/htmlunit/html/DomText.java
@@ -134,7 +134,7 @@ public String getNodeName() {
protected boolean printXml(final String indent, final boolean tagBefore, final PrintWriter printWriter) {
String data = getData();
boolean tag = tagBefore;
- if (org.apache.commons.lang3.StringUtils.isNotBlank(data)) {
+ if (StringUtils.isNotBlank(data)) {
if (!(getParentNode() instanceof HtmlStyle) || !data.startsWith("")) {
data = StringUtils.escapeXmlChars(data);
}
diff --git a/src/main/java/org/htmlunit/html/HtmlAnchor.java b/src/main/java/org/htmlunit/html/HtmlAnchor.java
index 6cf7560323f..a737a3002dc 100644
--- a/src/main/java/org/htmlunit/html/HtmlAnchor.java
+++ b/src/main/java/org/htmlunit/html/HtmlAnchor.java
@@ -23,8 +23,6 @@
import java.util.Map;
import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.Strings;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.htmlunit.BrowserVersion;
@@ -38,6 +36,7 @@
import org.htmlunit.javascript.host.event.Event;
import org.htmlunit.javascript.host.html.HTMLElement;
import org.htmlunit.protocol.javascript.JavaScriptURLConnection;
+import org.htmlunit.util.StringUtils;
import org.htmlunit.util.UrlUtils;
/**
@@ -117,7 +116,7 @@ protected void doClickStateUpdate(final boolean shiftKey, final boolean ctrlKey,
}
final String downloadAttribute = getDownloadAttribute();
HtmlPage page = (HtmlPage) getPage();
- if (Strings.CI.startsWith(href, JavaScriptURLConnection.JAVASCRIPT_PREFIX)) {
+ if (StringUtils.startsWithIgnoreCase(href, JavaScriptURLConnection.JAVASCRIPT_PREFIX)) {
final StringBuilder builder = new StringBuilder(href.length());
builder.append(JavaScriptURLConnection.JAVASCRIPT_PREFIX);
for (int i = JavaScriptURLConnection.JAVASCRIPT_PREFIX.length(); i < href.length(); i++) {
@@ -203,7 +202,7 @@ private boolean relContainsNoreferrer() {
String rel = getRelAttribute();
if (rel != null) {
rel = rel.toLowerCase(Locale.ROOT);
- return ArrayUtils.contains(org.htmlunit.util.StringUtils.splitAtBlank(rel), "noreferrer");
+ return ArrayUtils.contains(StringUtils.splitAtBlank(rel), "noreferrer");
}
return false;
}
@@ -219,7 +218,7 @@ private boolean relContainsNoreferrer() {
public static URL getTargetUrl(final String href, final HtmlPage page) throws MalformedURLException {
URL url = page.getFullyQualifiedUrl(href);
// fix for empty url
- if (StringUtils.isEmpty(href)) {
+ if (StringUtils.isEmptyOrNull(href)) {
url = UrlUtils.getUrlWithNewRef(url, null);
}
return url;
diff --git a/src/main/java/org/htmlunit/html/HtmlArea.java b/src/main/java/org/htmlunit/html/HtmlArea.java
index 6dcf7d79267..381639681df 100644
--- a/src/main/java/org/htmlunit/html/HtmlArea.java
+++ b/src/main/java/org/htmlunit/html/HtmlArea.java
@@ -22,8 +22,6 @@
import java.util.Arrays;
import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.Strings;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.htmlunit.SgmlPage;
@@ -32,6 +30,7 @@
import org.htmlunit.WebWindow;
import org.htmlunit.javascript.host.event.Event;
import org.htmlunit.protocol.javascript.JavaScriptURLConnection;
+import org.htmlunit.util.StringUtils;
import org.htmlunit.util.geometry.Circle2D;
import org.htmlunit.util.geometry.Polygon2D;
import org.htmlunit.util.geometry.Rectangle2D;
@@ -81,7 +80,7 @@ protected boolean doClickStateUpdate(final boolean shiftKey, final boolean ctrlK
final String href = getHrefAttribute().trim();
if (!href.isEmpty()) {
final HtmlPage page = (HtmlPage) getPage();
- if (Strings.CI.startsWith(href, JavaScriptURLConnection.JAVASCRIPT_PREFIX)) {
+ if (org.htmlunit.util.StringUtils.startsWithIgnoreCase(href, JavaScriptURLConnection.JAVASCRIPT_PREFIX)) {
page.executeJavaScript(
href, "javascript url", getStartLineNumber());
return false;
@@ -219,7 +218,7 @@ public final String getTargetAttribute() {
* @return {@code true} if the point is contained in this area
*/
boolean containsPoint(final int x, final int y) {
- final String shape = StringUtils.defaultIfEmpty(getShapeAttribute(), SHAPE_RECT);
+ final String shape = StringUtils.defaultIfEmptyOrNull(getShapeAttribute(), SHAPE_RECT);
if ("default".equalsIgnoreCase(shape) && getCoordsAttribute() != null) {
return true;
@@ -362,7 +361,7 @@ public boolean handles(final Event event) {
}
private boolean isEmpty() {
- final String shape = StringUtils.defaultIfEmpty(getShapeAttribute(), SHAPE_RECT);
+ final String shape = StringUtils.defaultIfEmptyOrNull(getShapeAttribute(), SHAPE_RECT);
if ("default".equalsIgnoreCase(shape) && getCoordsAttribute() != null) {
return false;
diff --git a/src/main/java/org/htmlunit/html/HtmlButton.java b/src/main/java/org/htmlunit/html/HtmlButton.java
index 9e5f5b8b26b..6c2fb55a26d 100644
--- a/src/main/java/org/htmlunit/html/HtmlButton.java
+++ b/src/main/java/org/htmlunit/html/HtmlButton.java
@@ -23,13 +23,13 @@
import java.util.HashSet;
import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.htmlunit.SgmlPage;
import org.htmlunit.javascript.host.event.Event;
import org.htmlunit.javascript.host.event.MouseEvent;
import org.htmlunit.util.NameValuePair;
+import org.htmlunit.util.StringUtils;
import org.w3c.dom.Node;
/**
@@ -330,7 +330,7 @@ public final String getOnBlurAttribute() {
@Override
protected void setAttributeNS(final String namespaceURI, final String qualifiedName, final String attributeValue,
final boolean notifyAttributeChangeListeners, final boolean notifyMutationObservers) {
- final String qualifiedNameLC = org.htmlunit.util.StringUtils.toRootLowerCase(qualifiedName);
+ final String qualifiedNameLC = StringUtils.toRootLowerCase(qualifiedName);
if (NAME_ATTRIBUTE.equals(qualifiedNameLC)) {
if (newNames_.isEmpty()) {
newNames_ = new HashSet<>();
@@ -412,7 +412,7 @@ public void setCustomValidity(final String message) {
*/
@Override
public boolean isCustomErrorValidityState() {
- return !StringUtils.isEmpty(customValidity_);
+ return !StringUtils.isEmptyOrNull(customValidity_);
}
@Override
diff --git a/src/main/java/org/htmlunit/html/HtmlColorInput.java b/src/main/java/org/htmlunit/html/HtmlColorInput.java
index 1184303ea32..363d1e7c545 100644
--- a/src/main/java/org/htmlunit/html/HtmlColorInput.java
+++ b/src/main/java/org/htmlunit/html/HtmlColorInput.java
@@ -16,9 +16,9 @@
import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
import org.htmlunit.SgmlPage;
import org.htmlunit.html.impl.Color;
+import org.htmlunit.util.StringUtils;
/**
* Wrapper for the HTML element "input" where type is "color".
@@ -57,7 +57,7 @@ public void setDefaultChecked(final boolean defaultChecked) {
*/
@Override
public void setValue(final String newValue) {
- if (StringUtils.isEmpty(newValue)) {
+ if (StringUtils.isEmptyOrNull(newValue)) {
super.setValue("#000000");
return;
}
@@ -73,7 +73,7 @@ protected void valueAttributeChanged(final String attributeValue, final boolean
return;
}
- if (StringUtils.isEmpty(attributeValue)) {
+ if (StringUtils.isEmptyOrNull(attributeValue)) {
setRawValue("#000000");
return;
}
diff --git a/src/main/java/org/htmlunit/html/HtmlDateInput.java b/src/main/java/org/htmlunit/html/HtmlDateInput.java
index e7bac09c29b..149f937ff2a 100644
--- a/src/main/java/org/htmlunit/html/HtmlDateInput.java
+++ b/src/main/java/org/htmlunit/html/HtmlDateInput.java
@@ -19,8 +19,8 @@
import java.time.format.DateTimeParseException;
import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
import org.htmlunit.SgmlPage;
+import org.htmlunit.util.StringUtils;
/**
* Wrapper for the HTML element "input" where type is "date".
@@ -136,7 +136,7 @@ private boolean isMaxValid() {
@Override
public void setValue(final String newValue) {
try {
- if (StringUtils.isNotEmpty(newValue)) {
+ if (!StringUtils.isEmptyOrNull(newValue)) {
FORMATTER_.parse(newValue);
}
super.setValue(newValue);
diff --git a/src/main/java/org/htmlunit/html/HtmlDateTimeLocalInput.java b/src/main/java/org/htmlunit/html/HtmlDateTimeLocalInput.java
index 6924a61c506..19d404bdd6a 100644
--- a/src/main/java/org/htmlunit/html/HtmlDateTimeLocalInput.java
+++ b/src/main/java/org/htmlunit/html/HtmlDateTimeLocalInput.java
@@ -19,9 +19,9 @@
import java.time.format.DateTimeParseException;
import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
import org.htmlunit.BrowserVersion;
import org.htmlunit.SgmlPage;
+import org.htmlunit.util.StringUtils;
/**
* Wrapper for the HTML element "input" where type is "datetime-local".
@@ -60,7 +60,7 @@ public void setDefaultChecked(final boolean defaultChecked) {
@Override
public void setValue(final String newValue) {
try {
- if (StringUtils.isNotEmpty(newValue)) {
+ if (!StringUtils.isEmptyOrNull(newValue)) {
FORMATTER_.parse(newValue);
}
super.setValue(newValue);
diff --git a/src/main/java/org/htmlunit/html/HtmlEmailInput.java b/src/main/java/org/htmlunit/html/HtmlEmailInput.java
index fb391a50ad0..b77f97d3b23 100644
--- a/src/main/java/org/htmlunit/html/HtmlEmailInput.java
+++ b/src/main/java/org/htmlunit/html/HtmlEmailInput.java
@@ -17,8 +17,8 @@
import java.util.Map;
import java.util.regex.Pattern;
-import org.apache.commons.lang3.StringUtils;
import org.htmlunit.SgmlPage;
+import org.htmlunit.util.StringUtils;
/**
* Wrapper for the HTML element "input" where type is "email".
diff --git a/src/main/java/org/htmlunit/html/HtmlFieldSet.java b/src/main/java/org/htmlunit/html/HtmlFieldSet.java
index 90d7a807eaa..5388da876a9 100644
--- a/src/main/java/org/htmlunit/html/HtmlFieldSet.java
+++ b/src/main/java/org/htmlunit/html/HtmlFieldSet.java
@@ -19,8 +19,8 @@
import java.util.HashSet;
import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
import org.htmlunit.SgmlPage;
+import org.htmlunit.util.StringUtils;
/**
* Wrapper for the HTML element "fieldset".
@@ -75,7 +75,7 @@ public void setCustomValidity(final String message) {
*/
@Override
public boolean isCustomErrorValidityState() {
- return !StringUtils.isEmpty(customValidity_);
+ return !StringUtils.isEmptyOrNull(customValidity_);
}
/**
diff --git a/src/main/java/org/htmlunit/html/HtmlFileInput.java b/src/main/java/org/htmlunit/html/HtmlFileInput.java
index 93b3cf4d309..40749beda19 100644
--- a/src/main/java/org/htmlunit/html/HtmlFileInput.java
+++ b/src/main/java/org/htmlunit/html/HtmlFileInput.java
@@ -24,13 +24,13 @@
import java.util.Map;
import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang3.StringUtils;
import org.htmlunit.BrowserVersion;
import org.htmlunit.SgmlPage;
import org.htmlunit.javascript.host.event.Event;
import org.htmlunit.util.KeyDataPair;
import org.htmlunit.util.MimeType;
import org.htmlunit.util.NameValuePair;
+import org.htmlunit.util.StringUtils;
/**
* Wrapper for the HTML element "input".
@@ -110,7 +110,7 @@ public NameValuePair[] getSubmitNameValuePairs() {
String contentType;
if (contentType_ == null) {
contentType = getPage().getWebClient().getBrowserVersion().getUploadMimeType(file);
- if (StringUtils.isEmpty(contentType)) {
+ if (StringUtils.isEmptyOrNull(contentType)) {
contentType = MimeType.APPLICATION_OCTET_STREAM;
}
}
@@ -181,7 +181,7 @@ public void setDefaultValue(final String defaultValue) {
*/
@Override
public void setValue(final String newValue) {
- if (StringUtils.isEmpty(newValue)) {
+ if (StringUtils.isEmptyOrNull(newValue)) {
setFiles();
return;
}
diff --git a/src/main/java/org/htmlunit/html/HtmlForm.java b/src/main/java/org/htmlunit/html/HtmlForm.java
index 1fb417a067c..97b55cd885d 100644
--- a/src/main/java/org/htmlunit/html/HtmlForm.java
+++ b/src/main/java/org/htmlunit/html/HtmlForm.java
@@ -34,7 +34,6 @@
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.Strings;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.htmlunit.BrowserVersion;
@@ -159,13 +158,15 @@ && getAttributeDirect(ATTRIBUTE_NOVALIDATE) != ATTRIBUTE_NOT_DEFINED) {
}
final String action = getActionAttribute().trim();
- if (Strings.CI.startsWith(action, JavaScriptURLConnection.JAVASCRIPT_PREFIX)) {
+ if (org.htmlunit.util.StringUtils.startsWithIgnoreCase(action,
+ JavaScriptURLConnection.JAVASCRIPT_PREFIX)) {
htmlPage.executeJavaScript(action, "Form action", getStartLineNumber());
return;
}
}
else {
- if (Strings.CI.startsWith(getActionAttribute(), JavaScriptURLConnection.JAVASCRIPT_PREFIX)) {
+ if (org.htmlunit.util.StringUtils.startsWithIgnoreCase(getActionAttribute(),
+ JavaScriptURLConnection.JAVASCRIPT_PREFIX)) {
// The action is JavaScript but JavaScript isn't enabled.
return;
}
@@ -272,7 +273,8 @@ public WebRequest getWebRequest(final SubmittableElement submitElement) {
method = HttpMethod.POST;
}
else {
- if (!"get".equalsIgnoreCase(methodAttribute) && StringUtils.isNotBlank(methodAttribute)) {
+ if (!"get".equalsIgnoreCase(methodAttribute)
+ && org.htmlunit.util.StringUtils.isNotBlank(methodAttribute)) {
notifyIncorrectness("Incorrect submit method >" + getMethodAttribute() + "<. Using >GET<.");
}
method = HttpMethod.GET;
diff --git a/src/main/java/org/htmlunit/html/HtmlImage.java b/src/main/java/org/htmlunit/html/HtmlImage.java
index 1955a7eba91..29688205197 100644
--- a/src/main/java/org/htmlunit/html/HtmlImage.java
+++ b/src/main/java/org/htmlunit/html/HtmlImage.java
@@ -31,7 +31,6 @@
import java.util.Map;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.htmlunit.BrowserVersion;
@@ -50,6 +49,7 @@
import org.htmlunit.platform.Platform;
import org.htmlunit.platform.geom.IntDimension2D;
import org.htmlunit.platform.image.ImageData;
+import org.htmlunit.util.StringUtils;
import org.htmlunit.util.UrlUtils;
/**
@@ -134,7 +134,7 @@ protected void setAttributeNS(final String namespaceURI, final String qualifiedN
final boolean notifyAttributeChangeListeners, final boolean notifyMutationObservers) {
final HtmlPage htmlPage = getHtmlPageOrNull();
- final String qualifiedNameLC = org.htmlunit.util.StringUtils.toRootLowerCase(qualifiedName);
+ final String qualifiedNameLC = StringUtils.toRootLowerCase(qualifiedName);
if (SRC_ATTRIBUTE.equals(qualifiedNameLC) && value != ATTRIBUTE_NOT_DEFINED && htmlPage != null) {
final String oldValue = getAttributeNS(namespaceURI, qualifiedNameLC);
if (!oldValue.equals(value)) {
@@ -349,7 +349,7 @@ public final String getSrcAttribute() {
*/
public String getSrc() {
final String src = getSrcAttribute();
- if (org.htmlunit.util.StringUtils.isEmptyString(src)) {
+ if (StringUtils.isEmptyString(src)) {
return src;
}
try {
@@ -526,10 +526,11 @@ public int getHeightOrDefault() {
final WebClient webClient = getPage().getWebClient();
final BrowserVersion browserVersion = webClient.getBrowserVersion();
- if (StringUtils.isEmpty(src)) {
+ if (StringUtils.isEmptyOrNull(src)) {
return 0;
}
- if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_16x16_0x0) && StringUtils.isBlank(src)) {
+ if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_16x16_0x0)
+ && StringUtils.isBlank(src)) {
return 0;
}
@@ -587,10 +588,11 @@ public int getWidthOrDefault() {
final WebClient webClient = getPage().getWebClient();
final BrowserVersion browserVersion = webClient.getBrowserVersion();
- if (StringUtils.isEmpty(src)) {
+ if (StringUtils.isEmptyOrNull(src)) {
return 0;
}
- if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_16x16_0x0) && StringUtils.isBlank(src)) {
+ if (browserVersion.hasFeature(JS_IMAGE_WIDTH_HEIGHT_RETURNS_16x16_0x0)
+ && StringUtils.isBlank(src)) {
return 0;
}
@@ -671,7 +673,7 @@ private void downloadImageIfNeeded() throws IOException {
// HTMLIMAGE_BLANK_SRC_AS_EMPTY
final String src = getSrcAttribute();
- if (!org.htmlunit.util.StringUtils.isEmptyString(src)) {
+ if (!StringUtils.isEmptyString(src)) {
final HtmlPage page = (HtmlPage) getPage();
final WebClient webClient = page.getWebClient();
final BrowserVersion browser = webClient.getBrowserVersion();
@@ -821,7 +823,7 @@ public boolean isDisplayed() {
if (hasFeature(HTMLIMAGE_BLANK_SRC_AS_EMPTY) && StringUtils.isBlank(src)) {
return false;
}
- if (hasFeature(HTMLIMAGE_EMPTY_SRC_DISPLAY_FALSE) && StringUtils.isEmpty(src)) {
+ if (hasFeature(HTMLIMAGE_EMPTY_SRC_DISPLAY_FALSE) && StringUtils.isEmptyOrNull(src)) {
return false;
}
diff --git a/src/main/java/org/htmlunit/html/HtmlImageInput.java b/src/main/java/org/htmlunit/html/HtmlImageInput.java
index fcbf85ab0ce..09a2a42b543 100644
--- a/src/main/java/org/htmlunit/html/HtmlImageInput.java
+++ b/src/main/java/org/htmlunit/html/HtmlImageInput.java
@@ -23,7 +23,6 @@
import java.util.Map;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
import org.htmlunit.BrowserVersion;
import org.htmlunit.ElementNotFoundException;
import org.htmlunit.Page;
@@ -33,6 +32,7 @@
import org.htmlunit.WebResponse;
import org.htmlunit.javascript.host.event.Event;
import org.htmlunit.util.NameValuePair;
+import org.htmlunit.util.StringUtils;
/**
* Wrapper for the HTML element "input".
@@ -75,7 +75,7 @@ public NameValuePair[] getSubmitNameValuePairs() {
final String name = getNameAttribute();
final String prefix;
// a clicked image without name sends parameter x and y
- if (StringUtils.isEmpty(name)) {
+ if (StringUtils.isEmptyOrNull(name)) {
prefix = "";
}
else {
@@ -214,7 +214,7 @@ public void setSrcAttribute(final String src) {
private void downloadImageIfNeeded() throws IOException {
if (!downloaded_) {
final String src = getSrc();
- if (!org.htmlunit.util.StringUtils.isEmptyString(src)) {
+ if (!StringUtils.isEmptyString(src)) {
final HtmlPage page = (HtmlPage) getPage();
final WebClient webClient = page.getWebClient();
diff --git a/src/main/java/org/htmlunit/html/HtmlInput.java b/src/main/java/org/htmlunit/html/HtmlInput.java
index 3473b74ac81..6328ef37093 100644
--- a/src/main/java/org/htmlunit/html/HtmlInput.java
+++ b/src/main/java/org/htmlunit/html/HtmlInput.java
@@ -26,7 +26,6 @@
import java.util.Locale;
import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.htmlunit.BrowserVersion;
@@ -43,6 +42,7 @@
import org.htmlunit.javascript.host.event.MouseEvent;
import org.htmlunit.javascript.host.html.HTMLInputElement;
import org.htmlunit.util.NameValuePair;
+import org.htmlunit.util.StringUtils;
import org.xml.sax.helpers.AttributesImpl;
/**
@@ -632,7 +632,7 @@ static Page executeOnChangeHandlerIfAppropriate(final HtmlElement htmlElement) {
@Override
protected void setAttributeNS(final String namespaceURI, final String qualifiedName, final String attributeValue,
final boolean notifyAttributeChangeListeners, final boolean notifyMutationObservers) {
- final String qualifiedNameLC = org.htmlunit.util.StringUtils.toRootLowerCase(qualifiedName);
+ final String qualifiedNameLC = StringUtils.toRootLowerCase(qualifiedName);
if (NAME_ATTRIBUTE.equals(qualifiedNameLC)) {
if (newNames_.isEmpty()) {
newNames_ = new HashSet<>();
@@ -1000,12 +1000,12 @@ private boolean isPatternValid() {
}
final String pattern = getPattern();
- if (StringUtils.isEmpty(pattern)) {
+ if (StringUtils.isEmptyOrNull(pattern)) {
return true;
}
final String value = getValue();
- if (StringUtils.isEmpty(value)) {
+ if (StringUtils.isEmptyOrNull(value)) {
return true;
}
if (!isBlankPatternValidated() && StringUtils.isBlank(value)) {
@@ -1062,7 +1062,7 @@ public boolean isSubmitable() {
@Override
public boolean isCustomErrorValidityState() {
- return !StringUtils.isEmpty(customValidity_);
+ return !StringUtils.isEmptyOrNull(customValidity_);
}
@Override
@@ -1125,7 +1125,7 @@ public final void setFormNoValidate(final boolean noValidate) {
public final String getType() {
final BrowserVersion browserVersion = getPage().getWebClient().getBrowserVersion();
String type = getTypeAttribute();
- type = org.htmlunit.util.StringUtils.toRootLowerCase(type);
+ type = StringUtils.toRootLowerCase(type);
return isSupported(type, browserVersion) ? type : "text";
}
@@ -1148,8 +1148,7 @@ public HtmlInput changeType(String newType, final boolean setThroughAttribute) {
final WebClient webClient = page.getWebClient();
final BrowserVersion browser = webClient.getBrowserVersion();
if (!currentType.equalsIgnoreCase(newType)) {
- if (!isSupported(org.htmlunit.util.StringUtils
- .toRootLowerCase(newType), browser)) {
+ if (!isSupported(StringUtils.toRootLowerCase(newType), browser)) {
if (setThroughAttribute) {
newType = "text";
}
diff --git a/src/main/java/org/htmlunit/html/HtmlLink.java b/src/main/java/org/htmlunit/html/HtmlLink.java
index 58b0dd33bb5..ba2f61b3fd8 100644
--- a/src/main/java/org/htmlunit/html/HtmlLink.java
+++ b/src/main/java/org/htmlunit/html/HtmlLink.java
@@ -214,13 +214,13 @@ public WebResponse getWebResponse(final boolean downloadIfNeeded, WebRequest req
&& webclient.getBrowserVersion()
.hasFeature(HTMLLINK_CHECK_RESPONSE_TYPE_FOR_STYLESHEET)) {
- if (org.apache.commons.lang3.StringUtils.isNotBlank(type)
+ if (StringUtils.isNotBlank(type)
&& !MimeType.TEXT_CSS.equals(type)) {
return null;
}
final String respType = response.getContentType();
- if (org.apache.commons.lang3.StringUtils.isNotBlank(respType)
+ if (StringUtils.isNotBlank(respType)
&& !MimeType.TEXT_CSS.equals(respType)) {
executeEvent(Event.TYPE_ERROR);
return response;
@@ -393,7 +393,7 @@ public boolean isModulePreloadLink() {
public boolean isActiveStyleSheetLink() {
if (isStyleSheetLink()) {
final String media = getMediaAttribute();
- if (org.apache.commons.lang3.StringUtils.isBlank(media)) {
+ if (StringUtils.isBlank(media)) {
return true;
}
diff --git a/src/main/java/org/htmlunit/html/HtmlMap.java b/src/main/java/org/htmlunit/html/HtmlMap.java
index d7a7f2638fe..438d71c6c00 100644
--- a/src/main/java/org/htmlunit/html/HtmlMap.java
+++ b/src/main/java/org/htmlunit/html/HtmlMap.java
@@ -16,8 +16,8 @@
import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
import org.htmlunit.SgmlPage;
+import org.htmlunit.util.StringUtils;
/**
* Wrapper for the HTML element "map".
diff --git a/src/main/java/org/htmlunit/html/HtmlMedia.java b/src/main/java/org/htmlunit/html/HtmlMedia.java
index 3adf013ca07..1c8d19579d2 100644
--- a/src/main/java/org/htmlunit/html/HtmlMedia.java
+++ b/src/main/java/org/htmlunit/html/HtmlMedia.java
@@ -17,8 +17,8 @@
import java.net.MalformedURLException;
import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
import org.htmlunit.SgmlPage;
+import org.htmlunit.util.StringUtils;
/**
* HTML Media element, e.g. {@link HtmlAudio} or {@link HtmlVideo}.
@@ -47,7 +47,7 @@ public class HtmlMedia extends HtmlElement {
* @return "probably", "maybe", or "". The current implementation returns ""
*/
public String canPlayType(final String type) {
- if (StringUtils.isAllBlank(type)) {
+ if (StringUtils.isBlank(type)) {
return "";
}
diff --git a/src/main/java/org/htmlunit/html/HtmlNumberInput.java b/src/main/java/org/htmlunit/html/HtmlNumberInput.java
index 4292478ac0d..4321cd8bd37 100644
--- a/src/main/java/org/htmlunit/html/HtmlNumberInput.java
+++ b/src/main/java/org/htmlunit/html/HtmlNumberInput.java
@@ -96,7 +96,7 @@ protected void doType(final char c, final boolean lastType) {
public String getValue() {
final String raw = getRawValue();
- if (StringUtils.isBlank(raw)) {
+ if (org.htmlunit.util.StringUtils.isBlank(raw)) {
return "";
}
@@ -133,7 +133,7 @@ public boolean isValid() {
}
String rawValue = getRawValue();
- if (StringUtils.isBlank(rawValue)) {
+ if (org.htmlunit.util.StringUtils.isBlank(rawValue)) {
return true;
}
diff --git a/src/main/java/org/htmlunit/html/HtmlObject.java b/src/main/java/org/htmlunit/html/HtmlObject.java
index f077a862402..da7c35858f6 100644
--- a/src/main/java/org/htmlunit/html/HtmlObject.java
+++ b/src/main/java/org/htmlunit/html/HtmlObject.java
@@ -16,11 +16,11 @@
import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.htmlunit.SgmlPage;
import org.htmlunit.javascript.host.html.HTMLObjectElement;
+import org.htmlunit.util.StringUtils;
import org.htmlunit.xml.XmlPage;
/**
@@ -312,7 +312,7 @@ public void setCustomValidity(final String message) {
@Override
public boolean isCustomErrorValidityState() {
- return !StringUtils.isEmpty(customValidity_);
+ return !StringUtils.isEmptyOrNull(customValidity_);
}
@Override
diff --git a/src/main/java/org/htmlunit/html/HtmlOutput.java b/src/main/java/org/htmlunit/html/HtmlOutput.java
index b2d12b10e70..3a1349ea504 100644
--- a/src/main/java/org/htmlunit/html/HtmlOutput.java
+++ b/src/main/java/org/htmlunit/html/HtmlOutput.java
@@ -19,8 +19,8 @@
import java.util.HashSet;
import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
import org.htmlunit.SgmlPage;
+import org.htmlunit.util.StringUtils;
/**
* Wrapper for the HTML element "output".
@@ -87,7 +87,7 @@ public boolean isValid() {
*/
@Override
public boolean isCustomErrorValidityState() {
- return !StringUtils.isEmpty(customValidity_);
+ return !org.htmlunit.util.StringUtils.isEmptyOrNull(customValidity_);
}
@Override
diff --git a/src/main/java/org/htmlunit/html/HtmlPage.java b/src/main/java/org/htmlunit/html/HtmlPage.java
index b5d236be33c..cb27d7ec8cc 100644
--- a/src/main/java/org/htmlunit/html/HtmlPage.java
+++ b/src/main/java/org/htmlunit/html/HtmlPage.java
@@ -43,7 +43,6 @@
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.Strings;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.htmlunit.Cache;
@@ -939,7 +938,8 @@ public ScriptResult executeJavaScript(String sourceCode, final String sourceName
return new ScriptResult(JavaScriptEngine.UNDEFINED);
}
- if (Strings.CI.startsWith(sourceCode, JavaScriptURLConnection.JAVASCRIPT_PREFIX)) {
+ if (org.htmlunit.util.StringUtils.startsWithIgnoreCase(sourceCode,
+ JavaScriptURLConnection.JAVASCRIPT_PREFIX)) {
sourceCode = sourceCode.substring(JavaScriptURLConnection.JAVASCRIPT_PREFIX.length()).trim();
if (sourceCode.startsWith("return ")) {
sourceCode = sourceCode.substring("return ".length());
@@ -979,7 +979,7 @@ JavaScriptLoadResult loadExternalJavaScriptFile(final String srcAttribute, final
throws FailingHttpStatusCodeException {
final WebClient client = getWebClient();
- if (StringUtils.isBlank(srcAttribute) || !client.isJavaScriptEnabled()) {
+ if (org.htmlunit.util.StringUtils.isBlank(srcAttribute) || !client.isJavaScriptEnabled()) {
return JavaScriptLoadResult.NOOP;
}
@@ -1396,7 +1396,7 @@ private void executeRefreshIfNeeded() throws IOException {
}
}
- if (StringUtils.isBlank(urlPart)) {
+ if (org.htmlunit.util.StringUtils.isBlank(urlPart)) {
//content='10; URL=' is treated as content='10'
url = getUrl();
}
@@ -2346,7 +2346,7 @@ else if (baseUrl_ != null) {
}
else {
final String href = base_.getHrefAttribute().trim();
- if (StringUtils.isEmpty(href)) {
+ if (org.htmlunit.util.StringUtils.isEmptyOrNull(href)) {
baseUrl = getUrl();
}
else {
diff --git a/src/main/java/org/htmlunit/html/HtmlSelect.java b/src/main/java/org/htmlunit/html/HtmlSelect.java
index a72f1c359b0..4a654360012 100644
--- a/src/main/java/org/htmlunit/html/HtmlSelect.java
+++ b/src/main/java/org/htmlunit/html/HtmlSelect.java
@@ -23,7 +23,6 @@
import java.util.List;
import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
import org.htmlunit.ElementNotFoundException;
import org.htmlunit.Page;
import org.htmlunit.SgmlPage;
@@ -31,6 +30,7 @@
import org.htmlunit.javascript.host.event.Event;
import org.htmlunit.javascript.host.event.MouseEvent;
import org.htmlunit.util.NameValuePair;
+import org.htmlunit.util.StringUtils;
import org.w3c.dom.Node;
/**
@@ -660,7 +660,7 @@ public final String getOnChangeAttribute() {
@Override
protected void setAttributeNS(final String namespaceURI, final String qualifiedName, final String attributeValue,
final boolean notifyAttributeChangeListeners, final boolean notifyMutationObservers) {
- final String qualifiedNameLC = org.htmlunit.util.StringUtils.toRootLowerCase(qualifiedName);
+ final String qualifiedNameLC = StringUtils.toRootLowerCase(qualifiedName);
if (DomElement.NAME_ATTRIBUTE.equals(qualifiedNameLC)) {
if (newNames_.isEmpty()) {
newNames_ = new HashSet<>();
@@ -800,7 +800,7 @@ public boolean isValid() {
*/
@Override
public boolean isCustomErrorValidityState() {
- return !StringUtils.isEmpty(customValidity_);
+ return !StringUtils.isEmptyOrNull(customValidity_);
}
@Override
diff --git a/src/main/java/org/htmlunit/html/HtmlTextArea.java b/src/main/java/org/htmlunit/html/HtmlTextArea.java
index 8bb9afbbd71..b5f272a302b 100644
--- a/src/main/java/org/htmlunit/html/HtmlTextArea.java
+++ b/src/main/java/org/htmlunit/html/HtmlTextArea.java
@@ -20,13 +20,13 @@
import java.util.HashSet;
import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
import org.htmlunit.SgmlPage;
import org.htmlunit.html.impl.SelectableTextInput;
import org.htmlunit.html.impl.SelectableTextSelectionDelegate;
import org.htmlunit.javascript.host.event.Event;
import org.htmlunit.javascript.host.event.MouseEvent;
import org.htmlunit.util.NameValuePair;
+import org.htmlunit.util.StringUtils;
import org.w3c.dom.Node;
/**
@@ -432,7 +432,7 @@ protected boolean printXml(final String indent, final boolean tagBefore, final P
printOpeningTagContentAsXml(printWriter);
printWriter.print(">");
- printWriter.print(org.htmlunit.util.StringUtils.escapeXml(getText()));
+ printWriter.print(StringUtils.escapeXml(getText()));
printWriter.print("");
return true;
}
@@ -518,7 +518,7 @@ public boolean isReadOnly() {
@Override
protected void setAttributeNS(final String namespaceURI, final String qualifiedName, final String attributeValue,
final boolean notifyAttributeChangeListeners, final boolean notifyMutationObservers) {
- final String qualifiedNameLC = org.htmlunit.util.StringUtils.toRootLowerCase(qualifiedName);
+ final String qualifiedNameLC = StringUtils.toRootLowerCase(qualifiedName);
if (DomElement.NAME_ATTRIBUTE.equals(qualifiedNameLC)) {
if (newNames_.isEmpty()) {
newNames_ = new HashSet<>();
@@ -630,7 +630,7 @@ public boolean isValid() {
*/
@Override
public boolean isCustomErrorValidityState() {
- return !StringUtils.isEmpty(customValidity_);
+ return !StringUtils.isEmptyOrNull(customValidity_);
}
@Override
diff --git a/src/main/java/org/htmlunit/html/HtmlTimeInput.java b/src/main/java/org/htmlunit/html/HtmlTimeInput.java
index 74f38e37021..fbe6ed95798 100644
--- a/src/main/java/org/htmlunit/html/HtmlTimeInput.java
+++ b/src/main/java/org/htmlunit/html/HtmlTimeInput.java
@@ -23,9 +23,9 @@
import java.util.Locale;
import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
import org.htmlunit.BrowserVersion;
import org.htmlunit.SgmlPage;
+import org.htmlunit.util.StringUtils;
/**
* Wrapper for the HTML element "input" where type is "time".
diff --git a/src/main/java/org/htmlunit/html/HtmlUrlInput.java b/src/main/java/org/htmlunit/html/HtmlUrlInput.java
index a94157b7e26..8fde0600153 100644
--- a/src/main/java/org/htmlunit/html/HtmlUrlInput.java
+++ b/src/main/java/org/htmlunit/html/HtmlUrlInput.java
@@ -16,8 +16,8 @@
import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
import org.htmlunit.SgmlPage;
+import org.htmlunit.util.StringUtils;
/**
* Wrapper for the HTML element "input" where type is "url".
diff --git a/src/main/java/org/htmlunit/html/HtmlWeekInput.java b/src/main/java/org/htmlunit/html/HtmlWeekInput.java
index c94a7423dea..9b6f0ab1492 100644
--- a/src/main/java/org/htmlunit/html/HtmlWeekInput.java
+++ b/src/main/java/org/htmlunit/html/HtmlWeekInput.java
@@ -22,9 +22,9 @@
import java.time.format.DateTimeParseException;
import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
import org.htmlunit.BrowserVersion;
import org.htmlunit.SgmlPage;
+import org.htmlunit.util.StringUtils;
/**
* Wrapper for the HTML element "input" where type is "week".
@@ -63,7 +63,7 @@ public void setDefaultChecked(final boolean defaultChecked) {
@Override
public void setValue(final String newValue) {
if (!hasFeature(HTMLINPUT_TYPE_WEEK_SUPPORTED)
- || StringUtils.isEmpty(newValue)) {
+ || StringUtils.isEmptyOrNull(newValue)) {
super.setValue(newValue);
return;
}
diff --git a/src/main/java/org/htmlunit/html/ScriptElementSupport.java b/src/main/java/org/htmlunit/html/ScriptElementSupport.java
index 801fb7f55e3..b0645c68272 100644
--- a/src/main/java/org/htmlunit/html/ScriptElementSupport.java
+++ b/src/main/java/org/htmlunit/html/ScriptElementSupport.java
@@ -18,8 +18,6 @@
import java.nio.charset.Charset;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.Strings;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.htmlunit.FailingHttpStatusCodeException;
@@ -37,6 +35,7 @@
import org.htmlunit.protocol.javascript.JavaScriptURLConnection;
import org.htmlunit.util.EncodingSniffer;
import org.htmlunit.util.MimeType;
+import org.htmlunit.util.StringUtils;
import org.htmlunit.xml.XmlPage;
/**
@@ -293,12 +292,12 @@ private static boolean isExecutionNeeded(final ScriptElement script, final boole
public static boolean isJavaScript(String typeAttribute, final String languageAttribute) {
typeAttribute = typeAttribute.trim();
- if (StringUtils.isNotEmpty(typeAttribute)) {
+ if (!StringUtils.isEmptyOrNull(typeAttribute)) {
return MimeType.isJavascriptMimeType(typeAttribute);
}
- if (StringUtils.isNotEmpty(languageAttribute)) {
- return Strings.CI.startsWith(languageAttribute, "javascript");
+ if (!StringUtils.isEmptyOrNull(languageAttribute)) {
+ return org.htmlunit.util.StringUtils.startsWithIgnoreCase(languageAttribute, "javascript");
}
return true;
}
diff --git a/src/main/java/org/htmlunit/html/XmlSerializer.java b/src/main/java/org/htmlunit/html/XmlSerializer.java
index 14f9d99e324..41ff1bf91c0 100644
--- a/src/main/java/org/htmlunit/html/XmlSerializer.java
+++ b/src/main/java/org/htmlunit/html/XmlSerializer.java
@@ -281,7 +281,7 @@ private static String getFileExtension(final Page enclosedPage) {
protected Map getAttributesFor(final HtmlLink link) throws IOException {
final Map map = createAttributesCopyWithClonedAttribute(link, "href");
final DomAttr hrefAttr = map.get("href");
- if (hrefAttr != null && StringUtils.isNotBlank(hrefAttr.getValue())) {
+ if (hrefAttr != null && org.htmlunit.util.StringUtils.isNotBlank(hrefAttr.getValue())) {
final String protocol = link.getWebRequest().getUrl().getProtocol();
if ("http".equals(protocol) || "https".equals(protocol)) {
try {
@@ -312,7 +312,7 @@ protected Map getAttributesFor(final HtmlLink link) throws IOEx
protected Map getAttributesFor(final HtmlImage image) {
final Map map = createAttributesCopyWithClonedAttribute(image, DomElement.SRC_ATTRIBUTE);
final DomAttr srcAttr = map.get(DomElement.SRC_ATTRIBUTE);
- if (srcAttr != null && StringUtils.isNotBlank(srcAttr.getValue())) {
+ if (srcAttr != null && org.htmlunit.util.StringUtils.isNotBlank(srcAttr.getValue())) {
try {
final WebResponse response = image.getWebResponse(true);
diff --git a/src/main/java/org/htmlunit/html/parser/neko/HtmlUnitNekoDOMBuilder.java b/src/main/java/org/htmlunit/html/parser/neko/HtmlUnitNekoDOMBuilder.java
index cd61bd95e6c..98d3dab145b 100644
--- a/src/main/java/org/htmlunit/html/parser/neko/HtmlUnitNekoDOMBuilder.java
+++ b/src/main/java/org/htmlunit/html/parser/neko/HtmlUnitNekoDOMBuilder.java
@@ -40,6 +40,7 @@
import org.htmlunit.cyberneko.xerces.xni.XNIException;
import org.htmlunit.cyberneko.xerces.xni.parser.XMLInputSource;
import org.htmlunit.cyberneko.xerces.xni.parser.XMLParserConfiguration;
+import org.htmlunit.html.DomCDataSection;
import org.htmlunit.html.DomComment;
import org.htmlunit.html.DomDocumentType;
import org.htmlunit.html.DomElement;
@@ -546,7 +547,7 @@ private void handleCharacters() {
final String textValue = characters_.toString();
characters_.clear();
- if (org.apache.commons.lang3.StringUtils.isBlank(textValue)) {
+ if (StringUtils.isBlank(textValue)) {
appendChild(currentNode_, new DomText(page_, textValue));
return;
}
@@ -630,7 +631,11 @@ public void comment(final char[] ch, final int start, final int length) {
/** {@inheritDoc} */
@Override
public void endCDATA() {
- // nothing to do
+ final String data = characters_.toString();
+ characters_.clear();
+
+ final DomCDataSection cdataSection = new DomCDataSection(page_, data);
+ appendChild(currentNode_, cdataSection);
}
/** {@inheritDoc} */
@@ -648,7 +653,7 @@ public void endEntity(final String name) {
/** {@inheritDoc} */
@Override
public void startCDATA() {
- // nothing to do
+ handleCharacters();
}
/** {@inheritDoc} */
diff --git a/src/main/java/org/htmlunit/html/parser/neko/HtmlUnitNekoHtmlParser.java b/src/main/java/org/htmlunit/html/parser/neko/HtmlUnitNekoHtmlParser.java
index 24c79cb8ea7..5860d00976c 100644
--- a/src/main/java/org/htmlunit/html/parser/neko/HtmlUnitNekoHtmlParser.java
+++ b/src/main/java/org/htmlunit/html/parser/neko/HtmlUnitNekoHtmlParser.java
@@ -155,6 +155,7 @@ public void parse(final WebClient webClient, final WebResponse webResponse, fina
domBuilder.setFeature(HTMLScanner.ALLOW_SELFCLOSING_TAGS, true);
domBuilder.setFeature(HTMLScanner.SCRIPT_STRIP_CDATA_DELIMS, true);
domBuilder.setFeature(HTMLScanner.STYLE_STRIP_CDATA_DELIMS, true);
+ domBuilder.setFeature(HTMLScanner.CDATA_SECTIONS, true);
domBuilder.setFeature(HTMLScanner.CDATA_EARLY_CLOSING, false);
}
diff --git a/src/main/java/org/htmlunit/html/serializer/HtmlSerializerInnerOuterText.java b/src/main/java/org/htmlunit/html/serializer/HtmlSerializerInnerOuterText.java
index 455b1656f10..6f394f90ae8 100644
--- a/src/main/java/org/htmlunit/html/serializer/HtmlSerializerInnerOuterText.java
+++ b/src/main/java/org/htmlunit/html/serializer/HtmlSerializerInnerOuterText.java
@@ -16,7 +16,6 @@
import static org.htmlunit.BrowserVersionFeatures.JS_INNER_TEXT_SVG_NL;
-import org.apache.commons.lang3.StringUtils;
import org.htmlunit.BrowserVersion;
import org.htmlunit.SgmlPage;
import org.htmlunit.WebWindow;
@@ -40,6 +39,7 @@
import org.htmlunit.html.ScriptElement;
import org.htmlunit.html.serializer.HtmlSerializerInnerOuterText.HtmlSerializerTextBuilder.Mode;
import org.htmlunit.svg.SvgTitle;
+import org.htmlunit.util.StringUtils;
/**
* Special serializer to generate the output we need
@@ -261,7 +261,7 @@ private static Mode whiteSpaceStyle(final DomNode domNode, final Mode defaultMod
window.getComputedStyle((DomElement) domNode, null);
final String value = style.getStyleAttribute(Definition.WHITE_SPACE, false);
- if (StringUtils.isNoneEmpty(value)) {
+ if (!StringUtils.isEmptyOrNull(value)) {
if ("normal".equalsIgnoreCase(value)) {
return Mode.WHITE_SPACE_NORMAL;
}
diff --git a/src/main/java/org/htmlunit/html/serializer/HtmlSerializerVisibleText.java b/src/main/java/org/htmlunit/html/serializer/HtmlSerializerVisibleText.java
index cc3b345eabb..33bd616afb0 100644
--- a/src/main/java/org/htmlunit/html/serializer/HtmlSerializerVisibleText.java
+++ b/src/main/java/org/htmlunit/html/serializer/HtmlSerializerVisibleText.java
@@ -18,12 +18,12 @@
import java.util.List;
-import org.apache.commons.lang3.StringUtils;
import org.htmlunit.Page;
import org.htmlunit.SgmlPage;
import org.htmlunit.WebWindow;
import org.htmlunit.css.ComputedCssStyleDeclaration;
import org.htmlunit.css.StyleAttributes.Definition;
+import org.htmlunit.html.DomCDataSection;
import org.htmlunit.html.DomComment;
import org.htmlunit.html.DomElement;
import org.htmlunit.html.DomNode;
@@ -58,6 +58,7 @@
import org.htmlunit.html.HtmlUnorderedList;
import org.htmlunit.html.TableRowGroup;
import org.htmlunit.html.serializer.HtmlSerializerVisibleText.HtmlSerializerTextBuilder.Mode;
+import org.htmlunit.util.StringUtils;
/**
* Special serializer to generate the output we need
@@ -105,7 +106,10 @@ protected void appendChildren(final HtmlSerializerTextBuilder builder, final Dom
* @param mode the {@link Mode} to use for processing
*/
protected void appendNode(final HtmlSerializerTextBuilder builder, final DomNode node, final Mode mode) {
- if (node instanceof DomText) {
+ if (node instanceof DomCDataSection) {
+ // ignore
+ }
+ else if (node instanceof DomText) {
appendText(builder, (DomText) node, mode);
}
else if (node instanceof DomComment) {
@@ -683,7 +687,7 @@ protected Mode whiteSpaceStyle(final DomNode domNode, final Mode defaultMode) {
if (node instanceof DomElement) {
final ComputedCssStyleDeclaration style = window.getComputedStyle((DomElement) node, null);
final String value = style.getStyleAttribute(Definition.WHITE_SPACE, false);
- if (StringUtils.isNoneEmpty(value)) {
+ if (!StringUtils.isEmptyOrNull(value)) {
if ("normal".equalsIgnoreCase(value)) {
return Mode.WHITE_SPACE_NORMAL;
}
@@ -716,7 +720,7 @@ protected Mode updateWhiteSpaceStyle(final DomNode domNode, final Mode defaultMo
if (domNode instanceof DomElement) {
final ComputedCssStyleDeclaration style = window.getComputedStyle((DomElement) domNode, null);
final String value = style.getStyleAttribute(Definition.WHITE_SPACE, false);
- if (StringUtils.isNoneEmpty(value)) {
+ if (!StringUtils.isEmptyOrNull(value)) {
if ("normal".equalsIgnoreCase(value)) {
return Mode.WHITE_SPACE_NORMAL;
}
diff --git a/src/main/java/org/htmlunit/httpclient/HtmlUnitBrowserCompatCookieSpec.java b/src/main/java/org/htmlunit/httpclient/HtmlUnitBrowserCompatCookieSpec.java
index 977ce63d5d2..b603f2fde92 100644
--- a/src/main/java/org/htmlunit/httpclient/HtmlUnitBrowserCompatCookieSpec.java
+++ b/src/main/java/org/htmlunit/httpclient/HtmlUnitBrowserCompatCookieSpec.java
@@ -23,7 +23,6 @@
import java.util.List;
import java.util.Locale;
-import org.apache.commons.lang3.StringUtils;
import org.apache.http.FormattedHeader;
import org.apache.http.Header;
import org.apache.http.HeaderElement;
@@ -47,6 +46,7 @@
import org.apache.http.message.TokenParser;
import org.apache.http.util.CharArrayBuffer;
import org.htmlunit.BrowserVersion;
+import org.htmlunit.util.StringUtils;
/**
* Customized BrowserCompatSpec for HtmlUnit.
diff --git a/src/main/java/org/htmlunit/httpclient/HtmlUnitSameSiteHandler.java b/src/main/java/org/htmlunit/httpclient/HtmlUnitSameSiteHandler.java
index f9fb0fe5485..6a905599c0b 100644
--- a/src/main/java/org/htmlunit/httpclient/HtmlUnitSameSiteHandler.java
+++ b/src/main/java/org/htmlunit/httpclient/HtmlUnitSameSiteHandler.java
@@ -14,13 +14,13 @@
*/
package org.htmlunit.httpclient;
-import org.apache.commons.lang3.StringUtils;
import org.apache.http.cookie.CommonCookieAttributeHandler;
import org.apache.http.cookie.Cookie;
import org.apache.http.cookie.CookieOrigin;
import org.apache.http.cookie.MalformedCookieException;
import org.apache.http.cookie.SetCookie;
import org.apache.http.impl.cookie.BasicClientCookie;
+import org.htmlunit.util.StringUtils;
/**
* Customized CookieAttributeHandler for handling of the samesite attribute.
diff --git a/src/main/java/org/htmlunit/javascript/JavaScriptEngine.java b/src/main/java/org/htmlunit/javascript/JavaScriptEngine.java
index 5c68f040dea..ced5366e785 100644
--- a/src/main/java/org/htmlunit/javascript/JavaScriptEngine.java
+++ b/src/main/java/org/htmlunit/javascript/JavaScriptEngine.java
@@ -30,7 +30,6 @@
import java.util.Map;
import java.util.Map.Entry;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.htmlunit.BrowserVersion;
@@ -79,6 +78,7 @@
import org.htmlunit.javascript.host.intl.Intl;
import org.htmlunit.javascript.host.xml.FormData;
import org.htmlunit.javascript.polyfill.Polyfill;
+import org.htmlunit.util.StringUtils;
/**
* A wrapper for the Rhino JavaScript engine
@@ -290,7 +290,7 @@ public static void configureScope(final HtmlUnitScriptable jsScope,
final String jsClassName = config.getClassName();
Scriptable prototype = prototypesPerJSName.get(jsClassName);
final String extendedClassName =
- StringUtils.isEmpty(config.getExtendedClassName()) ? null : config.getExtendedClassName();
+ StringUtils.isEmptyOrNull(config.getExtendedClassName()) ? null : config.getExtendedClassName();
// setup the prototypes
if (config == scopeConfig) {
diff --git a/src/main/java/org/htmlunit/javascript/host/Element.java b/src/main/java/org/htmlunit/javascript/host/Element.java
index 2967bea2042..1e8a4b6ca2b 100644
--- a/src/main/java/org/htmlunit/javascript/host/Element.java
+++ b/src/main/java/org/htmlunit/javascript/host/Element.java
@@ -42,6 +42,7 @@
import org.htmlunit.css.ElementCssStyleDeclaration;
import org.htmlunit.cssparser.parser.CSSException;
import org.htmlunit.html.DomAttr;
+import org.htmlunit.html.DomCDataSection;
import org.htmlunit.html.DomCharacterData;
import org.htmlunit.html.DomComment;
import org.htmlunit.html.DomElement;
@@ -1008,6 +1009,9 @@ protected void printNode(final StringBuilder builder, final DomNode node, final
builder.append("");
}
}
+ else if (node instanceof DomCDataSection) {
+ builder.append("");
+ }
else if (node instanceof DomCharacterData) {
// Remove whitespace sequences, possibly escape XML characters.
String s = node.getNodeValue();
diff --git a/src/main/java/org/htmlunit/javascript/host/History.java b/src/main/java/org/htmlunit/javascript/host/History.java
index 3601a72c9b3..26986d17acd 100644
--- a/src/main/java/org/htmlunit/javascript/host/History.java
+++ b/src/main/java/org/htmlunit/javascript/host/History.java
@@ -18,7 +18,6 @@
import java.net.MalformedURLException;
import java.net.URL;
-import org.apache.commons.lang3.StringUtils;
import org.htmlunit.WebWindow;
import org.htmlunit.html.HtmlPage;
import org.htmlunit.javascript.HtmlUnitScriptable;
@@ -28,6 +27,7 @@
import org.htmlunit.javascript.configuration.JsxFunction;
import org.htmlunit.javascript.configuration.JsxGetter;
import org.htmlunit.javascript.configuration.JsxSetter;
+import org.htmlunit.util.StringUtils;
/**
* A JavaScript object for the client's browsing history.
diff --git a/src/main/java/org/htmlunit/javascript/host/Location.java b/src/main/java/org/htmlunit/javascript/host/Location.java
index 8bc57f34a0d..1a41596e5df 100644
--- a/src/main/java/org/htmlunit/javascript/host/Location.java
+++ b/src/main/java/org/htmlunit/javascript/host/Location.java
@@ -22,8 +22,6 @@
import java.net.MalformedURLException;
import java.net.URL;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.Strings;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.htmlunit.BrowserVersion;
@@ -39,6 +37,7 @@
import org.htmlunit.javascript.host.event.Event;
import org.htmlunit.javascript.host.event.HashChangeEvent;
import org.htmlunit.protocol.javascript.JavaScriptURLConnection;
+import org.htmlunit.util.StringUtils;
import org.htmlunit.util.UrlUtils;
/**
@@ -307,7 +306,7 @@ public void setHref(final String newLocation) throws IOException {
URL url = page.getFullyQualifiedUrl(newLocation);
// fix for empty url
- if (StringUtils.isEmpty(newLocation)) {
+ if (StringUtils.isEmptyOrNull(newLocation)) {
url = UrlUtils.getUrlWithNewRef(url, null);
}
@@ -334,11 +333,11 @@ public void setHref(final String newLocation) throws IOException {
public String getSearch() {
final URL url = getUrl();
final String search = url.getQuery();
- if (StringUtils.isEmpty(search)) {
+ if (StringUtils.isEmptyOrNull(search)) {
return "";
}
- if (Strings.CI.startsWith(url.getProtocol(), UrlUtils.ABOUT)
+ if (StringUtils.startsWithIgnoreCase(url.getProtocol(), UrlUtils.ABOUT)
&& window_.getWebWindow().getWebClient().getBrowserVersion()
.hasFeature(JS_LOCATION_IGNORE_QUERY_FOR_ABOUT_PROTOCOL)) {
return "";
@@ -368,7 +367,7 @@ public String getHash() {
hash = decodeHash(hash);
}
- if (StringUtils.isEmpty(hash)) {
+ if (StringUtils.isEmptyOrNull(hash)) {
// nothing to do
}
else {
diff --git a/src/main/java/org/htmlunit/javascript/host/MessagePort.java b/src/main/java/org/htmlunit/javascript/host/MessagePort.java
index a258692c40c..4f8f638daee 100644
--- a/src/main/java/org/htmlunit/javascript/host/MessagePort.java
+++ b/src/main/java/org/htmlunit/javascript/host/MessagePort.java
@@ -105,8 +105,9 @@ public void postMessage(final String message, final Object transfer) {
final Window w = getWindow();
final WebWindow webWindow = w.getWebWindow();
final Page page = webWindow.getEnclosedPage();
- final URL currentURL = page.getUrl();
+
final MessageEvent event = new MessageEvent();
+ final URL currentURL = page.getUrl();
final String origin = currentURL.getProtocol() + "://" + currentURL.getHost() + ':' + currentURL.getPort();
event.initMessageEvent(Event.TYPE_MESSAGE, false, false, message, origin, "", w, transfer);
event.setParentScope(port_);
diff --git a/src/main/java/org/htmlunit/javascript/host/Navigator.java b/src/main/java/org/htmlunit/javascript/host/Navigator.java
index 5639079b1a9..eded151f891 100644
--- a/src/main/java/org/htmlunit/javascript/host/Navigator.java
+++ b/src/main/java/org/htmlunit/javascript/host/Navigator.java
@@ -22,7 +22,6 @@
import java.util.ArrayList;
-import org.apache.commons.lang3.StringUtils;
import org.htmlunit.WebClient;
import org.htmlunit.corejs.javascript.Scriptable;
import org.htmlunit.javascript.HtmlUnitScriptable;
@@ -34,6 +33,7 @@
import org.htmlunit.javascript.host.geo.Geolocation;
import org.htmlunit.javascript.host.media.MediaDevices;
import org.htmlunit.javascript.host.network.NetworkInformation;
+import org.htmlunit.util.StringUtils;
/**
* A JavaScript object for {@code Navigator}.
@@ -106,16 +106,16 @@ public String getLanguage() {
@JsxGetter
public Scriptable getLanguages() {
final String acceptLang = getBrowserVersion().getAcceptLanguageHeader();
- if (StringUtils.isEmpty(acceptLang)) {
+ if (StringUtils.isEmptyOrNull(acceptLang)) {
return JavaScriptEngine.newArray(this, 0);
}
final ArrayList res = new ArrayList<>();
final String[] parts = org.htmlunit.util.StringUtils.splitAtComma(acceptLang);
for (final String part : parts) {
- if (!StringUtils.isEmpty(part)) {
- final String lang = StringUtils.substringBefore(part, ";").trim();
- if (!StringUtils.isEmpty(part)) {
+ if (!StringUtils.isEmptyOrNull(part)) {
+ final String lang = org.apache.commons.lang3.StringUtils.substringBefore(part, ";").trim();
+ if (!StringUtils.isEmptyOrNull(part)) {
res.add(lang);
}
}
diff --git a/src/main/java/org/htmlunit/javascript/host/URL.java b/src/main/java/org/htmlunit/javascript/host/URL.java
index 0de3ba46250..bdbdc23a9c0 100644
--- a/src/main/java/org/htmlunit/javascript/host/URL.java
+++ b/src/main/java/org/htmlunit/javascript/host/URL.java
@@ -66,7 +66,7 @@ public void jsConstructor(final String url, final Object base) {
}
try {
- if (StringUtils.isBlank(baseStr)) {
+ if (org.htmlunit.util.StringUtils.isBlank(baseStr)) {
url_ = UrlUtils.toUrlUnsafe(url);
}
else {
@@ -134,7 +134,7 @@ public void setHash(final String fragment) throws MalformedURLException {
if (url_ == null) {
return;
}
- url_ = UrlUtils.getUrlWithNewRef(url_, StringUtils.isEmpty(fragment) ? null : fragment);
+ url_ = UrlUtils.getUrlWithNewRef(url_, org.htmlunit.util.StringUtils.isEmptyOrNull(fragment) ? null : fragment);
}
/**
@@ -161,7 +161,7 @@ public void setHost(final String host) throws MalformedURLException {
}
String newHost = StringUtils.substringBefore(host, ':');
- if (StringUtils.isEmpty(newHost)) {
+ if (org.htmlunit.util.StringUtils.isEmptyOrNull(newHost)) {
return;
}
@@ -190,7 +190,7 @@ public void setHost(final String host) throws MalformedURLException {
url_ = UrlUtils.getUrlWithNewHost(url_, newHost);
final String newPort = StringUtils.substringAfter(host, ':');
- if (StringUtils.isNotBlank(newHost)) {
+ if (org.htmlunit.util.StringUtils.isNotBlank(newHost)) {
try {
url_ = UrlUtils.getUrlWithNewHostAndPort(url_, newHost, Integer.parseInt(newPort));
}
@@ -225,11 +225,11 @@ public String getHostname() {
@JsxSetter
public void setHostname(final String hostname) throws MalformedURLException {
if (getBrowserVersion().hasFeature(JS_ANCHOR_HOSTNAME_IGNORE_BLANK)) {
- if (!StringUtils.isBlank(hostname)) {
+ if (!org.htmlunit.util.StringUtils.isBlank(hostname)) {
url_ = UrlUtils.getUrlWithNewHost(url_, hostname);
}
}
- else if (!StringUtils.isEmpty(hostname)) {
+ else if (!org.htmlunit.util.StringUtils.isEmptyOrNull(hostname)) {
url_ = UrlUtils.getUrlWithNewHost(url_, hostname);
}
}
@@ -513,7 +513,7 @@ public Object getDefaultValue(final Class> hint) {
return super.getDefaultValue(hint);
}
- if (StringUtils.isEmpty(url_.getPath())) {
+ if (org.htmlunit.util.StringUtils.isEmptyOrNull(url_.getPath())) {
return url_.toExternalForm() + "/";
}
return url_.toExternalForm();
@@ -534,7 +534,7 @@ public String toJSON() {
*/
@JsxFunction(functionName = "toString")
public String jsToString() {
- if (StringUtils.isEmpty(url_.getPath())) {
+ if (org.htmlunit.util.StringUtils.isEmptyOrNull(url_.getPath())) {
try {
return UrlUtils.getUrlWithNewPath(url_, "/").toExternalForm();
}
diff --git a/src/main/java/org/htmlunit/javascript/host/URLSearchParams.java b/src/main/java/org/htmlunit/javascript/host/URLSearchParams.java
index 7e8f851c54d..3a4bd17b30a 100644
--- a/src/main/java/org/htmlunit/javascript/host/URLSearchParams.java
+++ b/src/main/java/org/htmlunit/javascript/host/URLSearchParams.java
@@ -246,7 +246,7 @@ private static List splitQuery(String params) {
final List splitted = new ArrayList<>();
params = StringUtils.stripStart(params, "?");
- if (StringUtils.isEmpty(params)) {
+ if (org.htmlunit.util.StringUtils.isEmptyOrNull(params)) {
return splitted;
}
diff --git a/src/main/java/org/htmlunit/javascript/host/Window.java b/src/main/java/org/htmlunit/javascript/host/Window.java
index 03c4861449e..c40e1d75d4a 100644
--- a/src/main/java/org/htmlunit/javascript/host/Window.java
+++ b/src/main/java/org/htmlunit/javascript/host/Window.java
@@ -35,7 +35,6 @@
import java.util.function.Predicate;
import java.util.function.Supplier;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.htmlunit.AlertHandler;
@@ -116,6 +115,7 @@
import org.htmlunit.javascript.host.performance.Performance;
import org.htmlunit.javascript.host.speech.SpeechSynthesis;
import org.htmlunit.javascript.host.xml.XMLDocument;
+import org.htmlunit.util.StringUtils;
import org.htmlunit.util.UrlUtils;
import org.htmlunit.xml.XmlPage;
@@ -445,7 +445,7 @@ public WindowProxy open(final Object url, final Object name, final Object featur
}
// if specified name is the name of an existing window, then hold it
- if (StringUtils.isEmpty(urlString) && !org.htmlunit.util.StringUtils.isEmptyString(windowName)) {
+ if (StringUtils.isEmptyOrNull(urlString) && !StringUtils.isEmptyString(windowName)) {
try {
final WebWindow webWindow = webClient.getWebWindowByName(windowName);
return getProxy(webWindow);
@@ -2000,9 +2000,9 @@ public static void postMessage(final Context context, final Scriptable scope,
final Page page = webWindow.getEnclosedPage();
final URL senderURL = page.getUrl();
- if (!org.htmlunit.util.StringUtils.equalsChar('*', targetOrigin)) {
+ if (!StringUtils.equalsChar('*', targetOrigin)) {
final URL targetURL;
- if (org.htmlunit.util.StringUtils.equalsChar('/', targetOrigin)) {
+ if (StringUtils.equalsChar('/', targetOrigin)) {
targetURL = senderURL;
}
else {
diff --git a/src/main/java/org/htmlunit/javascript/host/css/CSSStyleDeclaration.java b/src/main/java/org/htmlunit/javascript/host/css/CSSStyleDeclaration.java
index 418b18615d0..48c9dd75d31 100644
--- a/src/main/java/org/htmlunit/javascript/host/css/CSSStyleDeclaration.java
+++ b/src/main/java/org/htmlunit/javascript/host/css/CSSStyleDeclaration.java
@@ -38,7 +38,6 @@
import java.util.Set;
import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
import org.htmlunit.BrowserVersion;
import org.htmlunit.corejs.javascript.Scriptable;
import org.htmlunit.corejs.javascript.ScriptableObject;
@@ -58,6 +57,7 @@
import org.htmlunit.javascript.configuration.JsxSetter;
import org.htmlunit.javascript.configuration.JsxSymbol;
import org.htmlunit.javascript.host.Element;
+import org.htmlunit.util.StringUtils;
/**
* A JavaScript object for {@code CSSStyleDeclaration}.
@@ -1180,7 +1180,7 @@ public Object get(final String name, final Scriptable start) {
return value;
}
- final String camel = org.htmlunit.util.StringUtils.cssCamelize(name);
+ final String camel = StringUtils.cssCamelize(name);
if (!name.equals(camel)) {
value = prototype.get(camel, start);
if (value != Scriptable.NOT_FOUND) {
@@ -1249,7 +1249,7 @@ public void put(final String name, final Scriptable start, final Object value) {
prototype.put(name, start, value);
return;
}
- final String camel = org.htmlunit.util.StringUtils.cssCamelize(name);
+ final String camel = StringUtils.cssCamelize(name);
if (!name.equals(camel) && prototype.get(camel, start) != Scriptable.NOT_FOUND) {
prototype.put(camel, start, value);
return;
@@ -1800,7 +1800,7 @@ public String getZIndex() {
@JsxSetter
public void setZIndex(final Object zIndex) {
// empty
- if (zIndex == null || StringUtils.isEmpty(zIndex.toString())) {
+ if (zIndex == null || StringUtils.isEmptyOrNull(zIndex.toString())) {
setStyleAttribute(Definition.Z_INDEX_.getAttributeName(), "");
return;
}
@@ -1834,7 +1834,7 @@ public void setZIndex(final Object zIndex) {
@JsxFunction
public String getPropertyValue(final String name) {
if (name != null && name.contains("-")) {
- final Object value = getProperty(this, org.htmlunit.util.StringUtils.cssCamelize(name));
+ final Object value = getProperty(this, StringUtils.cssCamelize(name));
if (value instanceof String) {
return (String) value;
}
@@ -1863,7 +1863,7 @@ public String getPropertyPriority(final String name) {
@JsxFunction
public void setProperty(final String name, final Object value, final String important) {
String imp = "";
- if (!StringUtils.isEmpty(important) && !"null".equals(important)) {
+ if (!StringUtils.isEmptyOrNull(important) && !"null".equals(important)) {
if (!StyleElement.PRIORITY_IMPORTANT.equalsIgnoreCase(important)) {
return;
}
@@ -1973,7 +1973,7 @@ private void setStyleLengthAttribute(final String name, final Object value, fina
valueString = "";
}
- if (StringUtils.isEmpty(valueString)) {
+ if (StringUtils.isEmptyOrNull(valueString)) {
setStyleAttribute(name, valueString, important);
return;
}
diff --git a/src/main/java/org/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java b/src/main/java/org/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java
index e86e9f7f6cf..861c817f187 100644
--- a/src/main/java/org/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java
+++ b/src/main/java/org/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java
@@ -27,6 +27,7 @@
import org.htmlunit.javascript.configuration.JsxSymbol;
import org.htmlunit.javascript.configuration.JsxSymbolConstant;
import org.htmlunit.javascript.host.Element;
+import org.htmlunit.util.StringUtils;
/**
* An object for a CSSStyleDeclaration, which is computed.
@@ -540,7 +541,7 @@ public String getZIndex() {
@Override
public String getPropertyValue(final String name) {
// need to invoke the getter to take care of the default value
- final Object property = getProperty(this, org.htmlunit.util.StringUtils.cssCamelize(name));
+ final Object property = getProperty(this, StringUtils.cssCamelize(name));
if (property == NOT_FOUND) {
return super.getPropertyValue(name);
}
diff --git a/src/main/java/org/htmlunit/javascript/host/dom/DOMTokenList.java b/src/main/java/org/htmlunit/javascript/host/dom/DOMTokenList.java
index d39d11f3771..99ecc6ea51c 100644
--- a/src/main/java/org/htmlunit/javascript/host/dom/DOMTokenList.java
+++ b/src/main/java/org/htmlunit/javascript/host/dom/DOMTokenList.java
@@ -112,7 +112,7 @@ public void setValue(final String value) {
@JsxGetter
public int getLength() {
final String value = getValue();
- if (StringUtils.isBlank(value)) {
+ if (org.htmlunit.util.StringUtils.isBlank(value)) {
return 0;
}
@@ -154,7 +154,7 @@ public static void add(final Context context, final Scriptable scope,
for (final Object arg : args) {
final String token = JavaScriptEngine.toString(arg);
- if (StringUtils.isEmpty(token)) {
+ if (org.htmlunit.util.StringUtils.isEmptyOrNull(token)) {
throw JavaScriptEngine.asJavaScriptException(
(HtmlUnitScriptable) getTopLevelScope(thisObj),
"DOMTokenList: add() does not support empty tokens",
@@ -200,7 +200,7 @@ public static void remove(final Context context, final Scriptable scope,
for (final Object arg : args) {
final String token = JavaScriptEngine.toString(arg);
- if (StringUtils.isEmpty(token)) {
+ if (org.htmlunit.util.StringUtils.isEmptyOrNull(token)) {
throw JavaScriptEngine.asJavaScriptException(
(HtmlUnitScriptable) getTopLevelScope(thisObj),
"DOMTokenList: remove() does not support empty tokens",
@@ -228,7 +228,7 @@ public static void remove(final Context context, final Scriptable scope,
*/
@JsxFunction
public boolean replace(final String oldToken, final String newToken) {
- if (StringUtils.isEmpty(oldToken)) {
+ if (org.htmlunit.util.StringUtils.isEmptyOrNull(oldToken)) {
throw JavaScriptEngine.asJavaScriptException(
getWindow(),
"Empty oldToken not allowed",
@@ -241,7 +241,7 @@ public boolean replace(final String oldToken, final String newToken) {
DOMException.INVALID_CHARACTER_ERR);
}
- if (StringUtils.isEmpty(newToken)) {
+ if (org.htmlunit.util.StringUtils.isEmptyOrNull(newToken)) {
throw JavaScriptEngine.asJavaScriptException(
getWindow(),
"Empty newToken not allowed",
@@ -276,7 +276,7 @@ public boolean replace(final String oldToken, final String newToken) {
*/
@JsxFunction
public boolean toggle(final String token) {
- if (StringUtils.isEmpty(token)) {
+ if (org.htmlunit.util.StringUtils.isEmptyOrNull(token)) {
throw JavaScriptEngine.asJavaScriptException(
getWindow(),
"DOMTokenList: toggle() does not support empty tokens",
@@ -308,11 +308,11 @@ public boolean toggle(final String token) {
*/
@JsxFunction
public boolean contains(final String token) {
- if (StringUtils.isBlank(token)) {
+ if (org.htmlunit.util.StringUtils.isBlank(token)) {
return false;
}
- if (StringUtils.isEmpty(token)) {
+ if (org.htmlunit.util.StringUtils.isEmptyOrNull(token)) {
throw JavaScriptEngine.reportRuntimeError("DOMTokenList: contains() does not support empty tokens");
}
if (StringUtils.containsAny(token, WHITESPACE_CHARS)) {
@@ -336,7 +336,7 @@ public String item(final int index) {
}
final String value = getValue();
- if (StringUtils.isEmpty(value)) {
+ if (org.htmlunit.util.StringUtils.isEmptyOrNull(value)) {
return null;
}
@@ -365,7 +365,7 @@ public Object[] getIds() {
final Object[] normalIds = super.getIds();
final String value = getValue();
- if (StringUtils.isEmpty(value)) {
+ if (org.htmlunit.util.StringUtils.isEmptyOrNull(value)) {
return normalIds;
}
@@ -411,7 +411,7 @@ public void forEach(final Object callback) {
}
final String value = getValue();
- if (StringUtils.isEmpty(value)) {
+ if (org.htmlunit.util.StringUtils.isEmptyOrNull(value)) {
return;
}
@@ -460,7 +460,7 @@ private void updateAttribute(final String value) {
}
private static List split(final String value) {
- if (StringUtils.isEmpty(value)) {
+ if (org.htmlunit.util.StringUtils.isEmptyOrNull(value)) {
return new ArrayList<>();
}
diff --git a/src/main/java/org/htmlunit/javascript/host/dom/Document.java b/src/main/java/org/htmlunit/javascript/host/dom/Document.java
index b409b07ac88..8eafc0cdc85 100644
--- a/src/main/java/org/htmlunit/javascript/host/dom/Document.java
+++ b/src/main/java/org/htmlunit/javascript/host/dom/Document.java
@@ -44,7 +44,6 @@
import java.util.UUID;
import java.util.function.Predicate;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.htmlunit.HttpHeader;
@@ -127,6 +126,7 @@
import org.htmlunit.javascript.host.html.HTMLElement;
import org.htmlunit.javascript.host.html.HTMLFrameSetElement;
import org.htmlunit.util.Cookie;
+import org.htmlunit.util.StringUtils;
import org.htmlunit.util.UrlUtils;
import org.htmlunit.xpath.xml.utils.PrefixResolver;
import org.w3c.dom.CDATASection;
@@ -723,7 +723,7 @@ public HtmlUnitScriptable createElementNS(final String namespaceURI, final Strin
public HTMLCollection getElementsByTagName(final String tagName) {
final HTMLCollection collection = new HTMLCollection(getDomNodeOrDie(), false);
- if (org.htmlunit.util.StringUtils.equalsChar('*', tagName)) {
+ if (StringUtils.equalsChar('*', tagName)) {
collection.setIsMatchingPredicate((Predicate & Serializable) node -> true);
}
else {
diff --git a/src/main/java/org/htmlunit/javascript/host/file/Blob.java b/src/main/java/org/htmlunit/javascript/host/file/Blob.java
index 7d3fce2fba9..3bf5270da37 100644
--- a/src/main/java/org/htmlunit/javascript/host/file/Blob.java
+++ b/src/main/java/org/htmlunit/javascript/host/file/Blob.java
@@ -22,7 +22,6 @@
import java.nio.charset.Charset;
import java.util.Locale;
-import org.apache.commons.lang3.StringUtils;
import org.htmlunit.BrowserVersion;
import org.htmlunit.HttpHeader;
import org.htmlunit.WebRequest;
@@ -41,6 +40,7 @@
import org.htmlunit.javascript.host.ReadableStream;
import org.htmlunit.util.KeyDataPair;
import org.htmlunit.util.MimeType;
+import org.htmlunit.util.StringUtils;
/**
* A JavaScript object for {@code Blob}.
@@ -451,7 +451,7 @@ public void fillRequest(final WebRequest webRequest) {
*/
public KeyDataPair getKeyDataPair(final String name, final String fileName) {
String contentType = getType();
- if (StringUtils.isEmpty(contentType)) {
+ if (StringUtils.isEmptyOrNull(contentType)) {
contentType = MimeType.APPLICATION_OCTET_STREAM;
}
diff --git a/src/main/java/org/htmlunit/javascript/host/file/FileReader.java b/src/main/java/org/htmlunit/javascript/host/file/FileReader.java
index a2de02792e1..e11654292d3 100644
--- a/src/main/java/org/htmlunit/javascript/host/file/FileReader.java
+++ b/src/main/java/org/htmlunit/javascript/host/file/FileReader.java
@@ -22,7 +22,6 @@
import java.util.Locale;
import org.apache.commons.io.Charsets;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.htmlunit.corejs.javascript.Function;
@@ -39,6 +38,7 @@
import org.htmlunit.javascript.host.event.EventTarget;
import org.htmlunit.protocol.data.DataURLConnection;
import org.htmlunit.util.MimeType;
+import org.htmlunit.util.StringUtils;
/**
* A JavaScript object for {@code FileReader}.
@@ -109,7 +109,7 @@ public void readAsDataURL(final Object object) throws IOException {
final String value = new String(Base64.getEncoder().encode(bytes), StandardCharsets.US_ASCII);
String contentType = ((Blob) object).getType();
- if (StringUtils.isEmpty(contentType)) {
+ if (StringUtils.isEmptyOrNull(contentType)) {
contentType = MimeType.APPLICATION_OCTET_STREAM;
}
diff --git a/src/main/java/org/htmlunit/javascript/host/html/HTMLAnchorElement.java b/src/main/java/org/htmlunit/javascript/host/html/HTMLAnchorElement.java
index d3e114430aa..05c287036fd 100644
--- a/src/main/java/org/htmlunit/javascript/host/html/HTMLAnchorElement.java
+++ b/src/main/java/org/htmlunit/javascript/host/html/HTMLAnchorElement.java
@@ -213,7 +213,7 @@ public void setRev(final String rel) {
@JsxGetter
public String getReferrerPolicy() {
String attrib = getDomNodeOrDie().getAttribute("referrerPolicy");
- if (StringUtils.isEmpty(attrib)) {
+ if (org.htmlunit.util.StringUtils.isEmptyOrNull(attrib)) {
return "";
}
attrib = attrib.toLowerCase(Locale.ROOT);
@@ -376,11 +376,11 @@ public String getHostname() {
@JsxSetter
public void setHostname(final String hostname) throws Exception {
if (getBrowserVersion().hasFeature(JS_ANCHOR_HOSTNAME_IGNORE_BLANK)) {
- if (!StringUtils.isBlank(hostname)) {
+ if (!org.htmlunit.util.StringUtils.isBlank(hostname)) {
setUrl(UrlUtils.getUrlWithNewHost(getUrl(), hostname));
}
}
- else if (!StringUtils.isEmpty(hostname)) {
+ else if (!org.htmlunit.util.StringUtils.isEmptyOrNull(hostname)) {
setUrl(UrlUtils.getUrlWithNewHost(getUrl(), hostname));
}
}
diff --git a/src/main/java/org/htmlunit/javascript/host/html/HTMLElement.java b/src/main/java/org/htmlunit/javascript/host/html/HTMLElement.java
index 0860f72c79f..c66455c4787 100644
--- a/src/main/java/org/htmlunit/javascript/host/html/HTMLElement.java
+++ b/src/main/java/org/htmlunit/javascript/host/html/HTMLElement.java
@@ -446,7 +446,7 @@ public void setOuterText(final Object value) {
final DomNode domNode = getDomNodeOrDie();
final SgmlPage page = domNode.getPage();
- if (StringUtils.isEmpty(valueString)) {
+ if (org.htmlunit.util.StringUtils.isEmptyOrNull(valueString)) {
domNode.getParentNode().insertBefore(new DomText(page, ""), domNode);
}
else {
diff --git a/src/main/java/org/htmlunit/javascript/host/intl/DateTimeFormat.java b/src/main/java/org/htmlunit/javascript/host/intl/DateTimeFormat.java
index 5da304f8c20..e1a4e39cf92 100644
--- a/src/main/java/org/htmlunit/javascript/host/intl/DateTimeFormat.java
+++ b/src/main/java/org/htmlunit/javascript/host/intl/DateTimeFormat.java
@@ -27,7 +27,6 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import org.apache.commons.lang3.StringUtils;
import org.htmlunit.BrowserVersion;
import org.htmlunit.corejs.javascript.Context;
import org.htmlunit.corejs.javascript.Function;
@@ -40,6 +39,7 @@
import org.htmlunit.javascript.configuration.JsxConstructor;
import org.htmlunit.javascript.configuration.JsxFunction;
import org.htmlunit.javascript.host.Window;
+import org.htmlunit.util.StringUtils;
/**
* A JavaScript object for {@code DateTimeFormat}.
@@ -303,7 +303,7 @@ public Scriptable resolvedOptions() {
final Scriptable options = cx.newObject(getParentScope());
options.put("timeZone", options, cx.getTimeZone().getID());
- if (StringUtils.isEmpty(formatter_.locale_)) {
+ if (StringUtils.isEmptyOrNull(formatter_.locale_)) {
options.put("locale", options, cx.getLocale().toLanguageTag());
}
else {
diff --git a/src/main/java/org/htmlunit/javascript/host/worker/WorkerNavigator.java b/src/main/java/org/htmlunit/javascript/host/worker/WorkerNavigator.java
index fab7f586674..a1e80565477 100644
--- a/src/main/java/org/htmlunit/javascript/host/worker/WorkerNavigator.java
+++ b/src/main/java/org/htmlunit/javascript/host/worker/WorkerNavigator.java
@@ -111,16 +111,16 @@ public String getLanguage() {
@JsxGetter
public Scriptable getLanguages() {
final String acceptLang = getBrowserVersion().getAcceptLanguageHeader();
- if (StringUtils.isEmpty(acceptLang)) {
+ if (org.htmlunit.util.StringUtils.isEmptyOrNull(acceptLang)) {
return JavaScriptEngine.newArray(this, 0);
}
final ArrayList res = new ArrayList<>();
final String[] parts = org.htmlunit.util.StringUtils.splitAtComma(acceptLang);
for (final String part : parts) {
- if (!StringUtils.isEmpty(part)) {
+ if (!org.htmlunit.util.StringUtils.isEmptyOrNull(part)) {
final String lang = StringUtils.substringBefore(part, ";").trim();
- if (!StringUtils.isEmpty(part)) {
+ if (!org.htmlunit.util.StringUtils.isEmptyOrNull(part)) {
res.add(lang);
}
}
diff --git a/src/main/java/org/htmlunit/javascript/host/xml/FormData.java b/src/main/java/org/htmlunit/javascript/host/xml/FormData.java
index b4fa70f5992..cc419148985 100644
--- a/src/main/java/org/htmlunit/javascript/host/xml/FormData.java
+++ b/src/main/java/org/htmlunit/javascript/host/xml/FormData.java
@@ -19,7 +19,6 @@
import java.util.Iterator;
import java.util.List;
-import org.apache.commons.lang3.StringUtils;
import org.htmlunit.FormEncodingType;
import org.htmlunit.WebRequest;
import org.htmlunit.corejs.javascript.Context;
@@ -37,6 +36,7 @@
import org.htmlunit.javascript.host.file.File;
import org.htmlunit.javascript.host.html.HTMLFormElement;
import org.htmlunit.util.NameValuePair;
+import org.htmlunit.util.StringUtils;
/**
* A JavaScript object for {@code FormData}.
@@ -186,7 +186,7 @@ public void append(final String name, final Object value, final Object filename)
*/
@JsxFunction(functionName = "delete")
public void delete_js(final String name) {
- if (StringUtils.isEmpty(name)) {
+ if (StringUtils.isEmptyOrNull(name)) {
return;
}
@@ -199,7 +199,7 @@ public void delete_js(final String name) {
*/
@JsxFunction
public String get(final String name) {
- if (StringUtils.isEmpty(name)) {
+ if (StringUtils.isEmptyOrNull(name)) {
return null;
}
@@ -217,7 +217,7 @@ public String get(final String name) {
*/
@JsxFunction
public Scriptable getAll(final String name) {
- if (StringUtils.isEmpty(name)) {
+ if (StringUtils.isEmptyOrNull(name)) {
return JavaScriptEngine.newArray(this, 0);
}
@@ -238,7 +238,7 @@ public Scriptable getAll(final String name) {
*/
@JsxFunction
public boolean has(final String name) {
- if (StringUtils.isEmpty(name)) {
+ if (StringUtils.isEmptyOrNull(name)) {
return false;
}
@@ -259,7 +259,7 @@ public boolean has(final String name) {
*/
@JsxFunction
public void set(final String name, final Object value, final Object filename) {
- if (StringUtils.isEmpty(name)) {
+ if (StringUtils.isEmptyOrNull(name)) {
return;
}
diff --git a/src/main/java/org/htmlunit/javascript/host/xml/XMLDocument.java b/src/main/java/org/htmlunit/javascript/host/xml/XMLDocument.java
index 9573ec766fd..c13fa5d1641 100644
--- a/src/main/java/org/htmlunit/javascript/host/xml/XMLDocument.java
+++ b/src/main/java/org/htmlunit/javascript/host/xml/XMLDocument.java
@@ -18,7 +18,6 @@
import java.io.Serializable;
import java.util.function.Predicate;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.htmlunit.StringWebResponse;
@@ -38,6 +37,7 @@
import org.htmlunit.javascript.host.dom.Document;
import org.htmlunit.javascript.host.html.HTMLCollection;
import org.htmlunit.svg.SvgElement;
+import org.htmlunit.util.StringUtils;
import org.htmlunit.xml.XmlPage;
/**
@@ -100,7 +100,7 @@ public XMLDocument(final WebWindow enclosingWindow) {
public boolean loadXML(final String strXML) {
final WebWindow webWindow = getWindow().getWebWindow();
try {
- if (StringUtils.isEmpty(strXML)) {
+ if (StringUtils.isEmptyOrNull(strXML)) {
throw new IOException("Error parsing XML '" + strXML + "'");
}
diff --git a/src/main/java/org/htmlunit/javascript/host/xml/XMLHttpRequest.java b/src/main/java/org/htmlunit/javascript/host/xml/XMLHttpRequest.java
index ea4690d29de..53ded08d9c4 100644
--- a/src/main/java/org/htmlunit/javascript/host/xml/XMLHttpRequest.java
+++ b/src/main/java/org/htmlunit/javascript/host/xml/XMLHttpRequest.java
@@ -388,7 +388,7 @@ else if (RESPONSE_TYPE_DOCUMENT.equals(responseType_)) {
if (webResponse_ != null) {
String contentType = webResponse_.getContentType();
- if (StringUtils.isEmpty(contentType)) {
+ if (org.htmlunit.util.StringUtils.isEmptyOrNull(contentType)) {
contentType = MimeType.TEXT_XML;
}
return buildResponseXML(contentType);
@@ -521,7 +521,7 @@ public Object getResponseXML() {
}
String contentType = webResponse_.getContentType();
- if (StringUtils.isEmpty(contentType)) {
+ if (org.htmlunit.util.StringUtils.isEmptyOrNull(contentType)) {
contentType = MimeType.TEXT_XML;
}
diff --git a/src/main/java/org/htmlunit/platform/font/AwtFontUtil.java b/src/main/java/org/htmlunit/platform/font/AwtFontUtil.java
index e46f93ccab1..63b48d13f4d 100644
--- a/src/main/java/org/htmlunit/platform/font/AwtFontUtil.java
+++ b/src/main/java/org/htmlunit/platform/font/AwtFontUtil.java
@@ -36,7 +36,7 @@ public int countLines(final String content, final int pixelWidth, final String f
final int fontSizeInt = CssPixelValueConverter.pixelValue(fontSize);
final FontRenderContext fontRenderCtx = new FontRenderContext(null, false, true);
for (final String line : lines) {
- if (StringUtils.isBlank(line)) {
+ if (org.htmlunit.util.StringUtils.isBlank(line)) {
lineCount++;
}
else {
diff --git a/src/main/java/org/htmlunit/util/EncodingSniffer.java b/src/main/java/org/htmlunit/util/EncodingSniffer.java
index 1e4047d34e7..1953505db73 100644
--- a/src/main/java/org/htmlunit/util/EncodingSniffer.java
+++ b/src/main/java/org/htmlunit/util/EncodingSniffer.java
@@ -31,7 +31,6 @@
import org.apache.commons.io.ByteOrderMark;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.htmlunit.HttpHeader;
@@ -712,7 +711,7 @@ int getUpdatedIndex() {
* @return the normalized encoding name or null if not found
*/
public static String translateEncodingLabel(final String encodingLabel) {
- if (StringUtils.isEmpty(encodingLabel)) {
+ if (StringUtils.isEmptyOrNull(encodingLabel)) {
return null;
}
diff --git a/src/main/java/org/htmlunit/util/HeaderUtils.java b/src/main/java/org/htmlunit/util/HeaderUtils.java
index 7f1a4103700..9d8ac848441 100644
--- a/src/main/java/org/htmlunit/util/HeaderUtils.java
+++ b/src/main/java/org/htmlunit/util/HeaderUtils.java
@@ -17,7 +17,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.commons.lang3.Strings;
import org.htmlunit.HttpHeader;
import org.htmlunit.WebResponse;
@@ -110,10 +109,10 @@ public static boolean containsMaxAge(final WebResponse response) {
*/
public static boolean containsMaxAgeOrSMaxage(final WebResponse response) {
final String cacheControl = response.getResponseHeaderValue(HttpHeader.CACHE_CONTROL);
- if (Strings.CI.contains(cacheControl, CACHE_CONTROL_MAX_AGE)) {
+ if (StringUtils.containsIgnoreCase(cacheControl, CACHE_CONTROL_MAX_AGE)) {
return true;
}
- return Strings.CI.contains(cacheControl, CACHE_CONTROL_S_MAXAGE);
+ return StringUtils.containsIgnoreCase(cacheControl, CACHE_CONTROL_S_MAXAGE);
}
/**
@@ -153,6 +152,6 @@ private static long directiveValue(final WebResponse response, final Pattern pat
private static boolean containsCacheControlValue(final WebResponse response, final String value) {
final String cacheControl = response.getResponseHeaderValue(HttpHeader.CACHE_CONTROL);
- return Strings.CI.contains(cacheControl, value);
+ return StringUtils.containsIgnoreCase(cacheControl, value);
}
}
diff --git a/src/main/java/org/htmlunit/util/StringUtils.java b/src/main/java/org/htmlunit/util/StringUtils.java
index f75b9cc2ff8..f6ce4f39357 100644
--- a/src/main/java/org/htmlunit/util/StringUtils.java
+++ b/src/main/java/org/htmlunit/util/StringUtils.java
@@ -70,6 +70,77 @@ public static boolean isEmptyString(final CharSequence s) {
return s != null && s.length() == 0;
}
+ /**
+ * Returns true if the param is null or empty.
+ *
+ * @param s the string to check
+ * @return true if the param is null or empty
+ */
+ public static boolean isEmptyOrNull(final CharSequence s) {
+ return s == null || s.length() == 0;
+ }
+
+ /**
+ * Returns either the passed in CharSequence, or if the CharSequence is
+ * empty or {@code null}, the default value.
+ *
+ * @param the kind of CharSequence
+ * @param s the CharSequence to check
+ * @param defaultString the default to return if the input is empty or null
+ * @return the passed in CharSequence, or the defaultString
+ */
+ public static T defaultIfEmptyOrNull(final T s, final T defaultString) {
+ return isEmptyOrNull(s) ? defaultString : s;
+ }
+
+ /**
+ * Tests if a CharSequence is null, empty, or contains only whitespace.
+ *
+ * @param s the CharSequence to check
+ * @return true if a CharSequence is null, empty, or contains only whitespace
+ */
+ public static boolean isBlank(final CharSequence s) {
+ if (s == null) {
+ return true;
+ }
+
+ final int length = s.length();
+ if (length == 0) {
+ return true;
+ }
+
+ for (int i = 0; i < length; i++) {
+ if (!Character.isWhitespace(s.charAt(i))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Tests if a CharSequence is NOT null, empty, or contains only whitespace.
+ *
+ * @param s the CharSequence to check
+ * @return false if a CharSequence is null, empty, or contains only whitespace
+ */
+ public static boolean isNotBlank(final CharSequence s) {
+ if (s == null) {
+ return false;
+ }
+
+ final int length = s.length();
+ if (length == 0) {
+ return false;
+ }
+
+ for (int i = 0; i < length; i++) {
+ if (!Character.isWhitespace(s.charAt(i))) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* @param expected the char that we expect
* @param s the string to check
@@ -80,8 +151,10 @@ public static boolean equalsChar(final char expected, final CharSequence s) {
}
/**
+ * Tests if a CharSequence starts with a specified prefix.
+ *
* @param s the string to check
- * @param expectedStart the string that we expect at the beginning
+ * @param expectedStart the string that we expect at the beginning (has to be not null and not empty)
* @return true if the provided string has only one char and this matches the expectation
*/
public static boolean startsWithIgnoreCase(final String s, final String expectedStart) {
@@ -99,6 +172,66 @@ public static boolean startsWithIgnoreCase(final String s, final String expected
return s.regionMatches(true, 0, expectedStart, 0, expectedStart.length());
}
+ /**
+ * Tests if a CharSequence ends with a specified prefix.
+ *
+ * @param s the string to check
+ * @param expectedEnd the string that we expect at the end (has to be not null and not empty)
+ * @return true if the provided string has only one char and this matches the expectation
+ */
+ public static boolean endsWithIgnoreCase(final String s, final String expectedEnd) {
+ if (expectedEnd == null) {
+ throw new IllegalArgumentException("Expected end string can't be null or empty");
+ }
+
+ final int expectedEndLength = expectedEnd.length();
+ if (expectedEndLength == 0) {
+ throw new IllegalArgumentException("Expected end string can't be null or empty");
+ }
+
+ if (s == null) {
+ return false;
+ }
+ if (s == expectedEnd) {
+ return true;
+ }
+
+ return s.regionMatches(true, s.length() - expectedEndLength, expectedEnd, 0, expectedEndLength);
+ }
+
+ /**
+ * Tests if a CharSequence ends with a specified prefix.
+ *
+ * @param s the string to check
+ * @param expected the string that we expect to be a substring (has to be not null and not empty)
+ * @return true if the provided string has only one char and this matches the expectation
+ */
+ public static boolean containsIgnoreCase(final String s, final String expected) {
+ if (expected == null) {
+ throw new IllegalArgumentException("Expected string can't be null or empty");
+ }
+
+ final int expectedLength = expected.length();
+ if (expectedLength == 0) {
+ throw new IllegalArgumentException("Expected string can't be null or empty");
+ }
+
+ if (s == null) {
+ return false;
+ }
+ if (s == expected) {
+ return true;
+ }
+
+ final int max = s.length() - expectedLength;
+ for (int i = 0; i <= max; i++) {
+ if (s.regionMatches(true, i, expected, 0, expectedLength)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Escapes the characters '<', '>' and '&' into their XML entity equivalents.
*
@@ -625,7 +758,7 @@ public static String[] splitAtComma(final String str) {
* Splits the provided text into an array, using comma or blank as the
* separator.
*
- * @param str the String to parse, may be null
+ * @param str the String to parse, may be null
* @return an array of parsed Strings, an empty array if null String input
*/
public static String[] splitAtCommaOrBlank(final String str) {
diff --git a/src/main/java/org/htmlunit/util/UrlUtils.java b/src/main/java/org/htmlunit/util/UrlUtils.java
index ae43d1c6804..8d99ad1b271 100644
--- a/src/main/java/org/htmlunit/util/UrlUtils.java
+++ b/src/main/java/org/htmlunit/util/UrlUtils.java
@@ -236,7 +236,7 @@ public static URL toUrlUnsafe(final String url) throws MalformedURLException {
if (protocol.isEmpty() || UrlUtils.isNormalUrlProtocol(protocol)) {
final URL response = new URL(url);
if (response.getProtocol().startsWith("http")
- && org.apache.commons.lang3.StringUtils.isEmpty(response.getHost())) {
+ && StringUtils.isEmptyOrNull(response.getHost())) {
throw new MalformedURLException("Missing host name in url: " + url);
}
return response;
@@ -247,7 +247,7 @@ public static URL toUrlUnsafe(final String url) throws MalformedURLException {
}
if (ABOUT.equals(protocol)) {
- if (org.apache.commons.lang3.Strings.CI.equals(ABOUT_BLANK, url)) {
+ if (ABOUT_BLANK.equalsIgnoreCase(url)) {
return URL_ABOUT_BLANK;
}
return new URL(null, url, ABOUT_HANDLER);
@@ -536,7 +536,7 @@ public static URL getUrlWithProtocolAndAuthority(final URL u) throws MalformedUR
public static URL getUrlWithNewUserName(final URL u, final String newUserName) throws MalformedURLException {
String newUserInfo = newUserName == null ? "" : newUserName;
final String userInfo = u.getUserInfo();
- if (org.apache.commons.lang3.StringUtils.isNotBlank(userInfo)) {
+ if (StringUtils.isNotBlank(userInfo)) {
final int colonIdx = userInfo.indexOf(':');
if (colonIdx > -1) {
newUserInfo = newUserInfo + userInfo.substring(colonIdx);
@@ -557,7 +557,7 @@ public static URL getUrlWithNewUserPassword(final URL u, final String newUserPas
throws MalformedURLException {
String newUserInfo = newUserPassword == null ? "" : ':' + newUserPassword;
final String userInfo = u.getUserInfo();
- if (org.apache.commons.lang3.StringUtils.isNotBlank(userInfo)) {
+ if (StringUtils.isNotBlank(userInfo)) {
final int colonIdx = userInfo.indexOf(':');
if (colonIdx > -1) {
newUserInfo = userInfo.substring(0, colonIdx) + newUserInfo;
diff --git a/src/main/java/org/htmlunit/util/brotli/BitReader.java b/src/main/java/org/htmlunit/util/brotli/BitReader.java
new file mode 100644
index 00000000000..3f3e70b80c0
--- /dev/null
+++ b/src/main/java/org/htmlunit/util/brotli/BitReader.java
@@ -0,0 +1,312 @@
+/* Copyright 2015 Google Inc. All Rights Reserved.
+
+ Distributed under MIT license.
+ See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
+*/
+
+package org.htmlunit.util.brotli;
+
+import static org.htmlunit.util.brotli.BrotliError.BROTLI_ERROR;
+import static org.htmlunit.util.brotli.BrotliError.BROTLI_ERROR_CORRUPTED_PADDING_BITS;
+import static org.htmlunit.util.brotli.BrotliError.BROTLI_ERROR_READ_AFTER_END;
+import static org.htmlunit.util.brotli.BrotliError.BROTLI_ERROR_TRUNCATED_INPUT;
+import static org.htmlunit.util.brotli.BrotliError.BROTLI_ERROR_UNUSED_BYTES_AFTER_END;
+import static org.htmlunit.util.brotli.BrotliError.BROTLI_OK;
+import static org.htmlunit.util.brotli.BrotliError.BROTLI_PANIC_UNALIGNED_COPY_BYTES;
+
+/**
+ * Bit reading helpers.
+ */
+final class BitReader {
+
+ // Possible values: {5, 6}. 5 corresponds to 32-bit build, 6 to 64-bit. This value is used for
+ // JIT conditional compilation.
+ private static final int LOG_BITNESS = Utils.getLogBintness();
+
+ // Not only Java compiler prunes "if (const false)" code, but JVM as well.
+ // Code under "if (BIT_READER_DEBUG != 0)" have zero performance impact (outside unit tests).
+ private static final int BIT_READER_DEBUG = Utils.isDebugMode();
+
+ static final int BITNESS = 1 << LOG_BITNESS;
+
+ private static final int BYTENESS = BITNESS / 8;
+ private static final int CAPACITY = 4096;
+ // After encountering the end of the input stream, this amount of zero bytes will be appended.
+ private static final int SLACK = 64;
+ private static final int BUFFER_SIZE = CAPACITY + SLACK;
+ // Don't bother to replenish the buffer while this number of bytes is available.
+ private static final int SAFEGUARD = 36;
+ private static final int WATERLINE = CAPACITY - SAFEGUARD;
+
+ // "Half" refers to "half of native integer type", i.e. on 64-bit machines it is 32-bit type,
+ // on 32-bit machines it is 16-bit.
+ private static final int HALF_BITNESS = BITNESS / 2;
+ private static final int HALF_SIZE = BYTENESS / 2;
+ private static final int HALVES_CAPACITY = CAPACITY / HALF_SIZE;
+ private static final int HALF_BUFFER_SIZE = BUFFER_SIZE / HALF_SIZE;
+
+ private static final int LOG_HALF_SIZE = LOG_BITNESS - 4;
+
+ static final int HALF_WATERLINE = WATERLINE / HALF_SIZE;
+
+ /**
+ * Fills up the input buffer.
+ *
+ *