pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1857467 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Hex.java
Date Sat, 13 Apr 2019 11:21:11 GMT
Author: tilman
Date: Sat Apr 13 11:21:11 2019
New Revision: 1857467

URL: http://svn.apache.org/viewvc?rev=1857467&view=rev
Log:
PDFBOX-4513: SonarQube fix

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Hex.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Hex.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Hex.java?rev=1857467&r1=1857466&r2=1857467&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Hex.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Hex.java Sat Apr 13 11:21:11
2019
@@ -230,22 +230,26 @@ public final class Hex
     public static byte[] decodeHex(String s) throws IOException
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        for (int i = 0; i < s.length() - 1; i += 2)
+        int i = 0;
+        while (i < s.length() - 1)
         {
             if (s.charAt(i) == '\n' || s.charAt(i) == '\r')
             {
-                --i;
-                continue;
+                ++i;
             }
-            String hexByte = s.substring(i, i + 2);
-            try
+            else
             {
-                baos.write(Integer.parseInt(hexByte, 16)); // Byte.parseByte won't work with
"9C"
-            }
-            catch (NumberFormatException ex)
-            {
-                LOG.error("Can't parse " + hexByte + ", aborting decode", ex);
-                break;
+                String hexByte = s.substring(i, i + 2);
+                try
+                {
+                    baos.write(Integer.parseInt(hexByte, 16)); // Byte.parseByte won't work
with "9C"
+                }
+                catch (NumberFormatException ex)
+                {
+                    LOG.error("Can't parse " + hexByte + ", aborting decode", ex);
+                    break;
+                }
+                i += 2;
             }
         }
         return baos.toByteArray();



Mime
View raw message