From 97938e3f1c153246f9f49a1f57f562f77d8ac187 Mon Sep 17 00:00:00 2001 From: Ronald Brill Date: Fri, 3 Jan 2025 11:59:00 +0100 Subject: [PATCH] checkstyle --- .../htmlunit/protocol/data/DataUrlDecoder.java | 1 + src/main/java/org/htmlunit/util/UrlUtils.java | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/htmlunit/protocol/data/DataUrlDecoder.java b/src/main/java/org/htmlunit/protocol/data/DataUrlDecoder.java index 15891265ec..1c1018ec96 100644 --- a/src/main/java/org/htmlunit/protocol/data/DataUrlDecoder.java +++ b/src/main/java/org/htmlunit/protocol/data/DataUrlDecoder.java @@ -24,6 +24,7 @@ import java.nio.charset.UnsupportedCharsetException; import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang3.StringUtils; import org.htmlunit.util.MimeType; import org.htmlunit.util.UrlUtils; diff --git a/src/main/java/org/htmlunit/util/UrlUtils.java b/src/main/java/org/htmlunit/util/UrlUtils.java index 729161d9e0..226ec5c5fa 100644 --- a/src/main/java/org/htmlunit/util/UrlUtils.java +++ b/src/main/java/org/htmlunit/util/UrlUtils.java @@ -1404,7 +1404,7 @@ public static byte[] decodeDataUrl(final byte[] bytes) throws IllegalArgumentExc return buffer.toByteArray(); } - public static final byte[] decodeUrl(final byte[] bytes) throws IllegalArgumentException { + public static byte[] decodeUrl(final byte[] bytes) throws IllegalArgumentException { if (bytes == null) { return null; } @@ -1413,15 +1413,18 @@ public static final byte[] decodeUrl(final byte[] bytes) throws IllegalArgumentE final int b = bytes[i]; if (b == '+') { buffer.write(' '); - } else if (b == '%') { + } + else if (b == '%') { try { final int u = digit16(bytes[++i]); final int l = digit16(bytes[++i]); buffer.write((char) ((u << 4) + l)); - } catch (final ArrayIndexOutOfBoundsException e) { + } + catch (final ArrayIndexOutOfBoundsException e) { throw new IllegalArgumentException("Invalid URL encoding: ", e); } - } else { + } + else { buffer.write(b); } } @@ -1437,7 +1440,7 @@ private static int digit16(final byte b) throws IllegalArgumentException { } // adapted from apache commons codec - public static final byte[] encodeUrl(BitSet urlsafe, final byte[] bytes) { + public static byte[] encodeUrl(final BitSet urlsafe, final byte[] bytes) { if (bytes == null) { return null; } @@ -1453,7 +1456,8 @@ public static final byte[] encodeUrl(BitSet urlsafe, final byte[] bytes) { b = '+'; } buffer.write(b); - } else { + } + else { buffer.write('%'); final char hex1 = hexDigit(b >> 4); final char hex2 = hexDigit(b);