pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1751943 - in /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font: PDSimpleFont.java encoding/DictionaryEncoding.java
Date Fri, 08 Jul 2016 16:54:01 GMT
Author: jahewson
Date: Fri Jul  8 16:54:01 2016
New Revision: 1751943

URL: http://svn.apache.org/viewvc?rev=1751943&view=rev
Log:
PDFBOX-3403: Ignore invalid BaseEncoding names

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/DictionaryEncoding.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java?rev=1751943&r1=1751942&r2=1751943&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java
Fri Jul  8 16:54:01 2016
@@ -111,7 +111,13 @@ public abstract class PDSimpleFont exten
                 Encoding builtIn = null;
                 Boolean symbolic = getSymbolicFlag();
                 boolean isFlaggedAsSymbolic = symbolic != null && symbolic;
-                if (!encodingDict.containsKey(COSName.BASE_ENCODING) && isFlaggedAsSymbolic)
+
+                COSName baseEncoding = encodingDict.getCOSName(COSName.BASE_ENCODING);
+                
+                boolean hasValidBaseEncoding = baseEncoding != null &&
+                            Encoding.getInstance(baseEncoding) != null;
+                
+                if (!hasValidBaseEncoding && isFlaggedAsSymbolic)
                 {
                     builtIn = readEncodingFromFont();
                 }
@@ -142,7 +148,7 @@ public abstract class PDSimpleFont exten
             glyphList = GlyphList.getAdobeGlyphList();
         }
     }
-
+    
     /**
      * Called by readEncoding() if the encoding needs to be extracted from the font file.
      *

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/DictionaryEncoding.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/DictionaryEncoding.java?rev=1751943&r1=1751942&r2=1751943&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/DictionaryEncoding.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/DictionaryEncoding.java
Fri Jul  8 16:54:01 2016
@@ -99,7 +99,7 @@ public class DictionaryEncoding extends
         if (hasBaseEncoding)
         {
             COSName name = encoding.getCOSName(COSName.BASE_ENCODING);
-            base = Encoding.getInstance(name); // may be null
+            base = Encoding.getInstance(name); // null when the name is invalid
         }
 
         if (base == null)
@@ -116,14 +116,6 @@ public class DictionaryEncoding extends
                 {
                     base = builtIn;
                 }
-                else if (hasBaseEncoding)
-                {
-                    String name = encoding.getCOSName(COSName.BASE_ENCODING).getName();
-                    LOG.warn("Invalid BaseEncoding: " + name + ", using StandardEncoding
instead");
-                    
-                    // fallback to standard encoding (not in PDF spec, see PDFBOX-3403)
-                    base = StandardEncoding.INSTANCE;
-                }
                 else
                 {
                     // triggering this error indicates a bug in PDFBox. Every font should
always have



Mime
View raw message