diff --git a/pom.xml b/pom.xml
index 56c4577ace..45c42d209c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1204,6 +1204,10 @@
httpmime
${httpcomponents.version}
+
+ commons-codec
+ commons-codec
+
commons-logging
commons-logging
@@ -1263,6 +1267,11 @@
commons-logging
1.3.4
+
+ commons-codec
+ commons-codec
+ 1.17.1
+
org.brotli
dec
diff --git a/src/main/java/org/htmlunit/protocol/data/DataUrlDecoder.java b/src/main/java/org/htmlunit/protocol/data/DataUrlDecoder.java
index 236aed510f..1c1018ec96 100644
--- a/src/main/java/org/htmlunit/protocol/data/DataUrlDecoder.java
+++ b/src/main/java/org/htmlunit/protocol/data/DataUrlDecoder.java
@@ -22,8 +22,8 @@
import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.UnsupportedCharsetException;
-import java.util.Base64;
+import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import org.htmlunit.util.MimeType;
import org.htmlunit.util.UrlUtils;
@@ -92,7 +92,8 @@ public static DataUrlDecoder decodeDataURL(final String url) throws UnsupportedE
byte[] data = url.substring(comma + 1).getBytes(charset);
data = UrlUtils.decodeDataUrl(data);
if (base64) {
- data = Base64.getDecoder().decode(data);
+ // the commons codec decoder skip's invalid chars
+ data = Base64.decodeBase64(data);
}
return new DataUrlDecoder(data, mediaType, charset);
}