pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1594304 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java
Date Tue, 13 May 2014 17:54:38 GMT
Author: tilman
Date: Tue May 13 17:54:38 2014
New Revision: 1594304

URL: http://svn.apache.org/r1594304
Log:
PDFBOX-2073: Be more restrictive than the PDF spec

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java?rev=1594304&r1=1594303&r2=1594304&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java Tue May 13 17:54:38
2014
@@ -587,17 +587,26 @@ public final class COSName extends COSBa
         {
             int current = (bytes[i] + 256) % 256;
 
-            if (current <= 32 || current >= 127 || current == '(' || current == ')'
|| current == '[' || current == ']'
-                    || current == '/' || current == '%' || current == '<' || current ==
'>'
-                    || current == '{' || current == '}' // PDFBOX-2073                  
 
-                    || current == NAME_ESCAPE[0])
+            // Be more restrictive than the PDF spec, "Name Objects"
+            // see PDFBOX-2073
+            if ((current >= 'A' && current <= 'Z')
+                    || (current >= 'a' && current <= 'z')
+                    || (current >= '0' && current <= '9')
+                    || current == '+'
+                    || current == '-'
+                    || current == '_'
+                    || current == '@'
+                    || current == '*'
+                    || current == '$'
+                    || current == ';'
+                    || current == '.')
             {
-                output.write(NAME_ESCAPE);
-                output.write(COSHEXTable.TABLE[current]);
+                output.write(current);
             }
             else
             {
-                output.write(current);
+                output.write(NAME_ESCAPE);
+                output.write(COSHEXTable.TABLE[current]);
             }
         }
     }



Mime
View raw message