You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2019/06/26 17:30:29 UTC

svn commit: r1862170 - /pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphSubstitutionTable.java

Author: tilman
Date: Wed Jun 26 17:30:29 2019
New Revision: 1862170

URL: http://svn.apache.org/viewvc?rev=1862170&view=rev
Log:
PDFBOX-4580: check order of FeatureRecord array in the hope to detect corrupt table

Modified:
    pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphSubstitutionTable.java

Modified: pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphSubstitutionTable.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphSubstitutionTable.java?rev=1862170&r1=1862169&r2=1862170&view=diff
==============================================================================
--- pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphSubstitutionTable.java (original)
+++ pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphSubstitutionTable.java Wed Jun 26 17:30:29 2019
@@ -201,6 +201,14 @@ public class GlyphSubstitutionTable exte
         for (int i = 0; i < featureCount; i++)
         {
             featureTags[i] = data.readString(4);
+            if (i > 0 && featureTags[i].compareTo(featureTags[i-1]) < 0)
+            {
+                // catch corrupt file
+                // https://docs.microsoft.com/en-us/typography/opentype/spec/chapter2#flTbl
+                LOG.error("FeatureRecord array not alphabetically sorted by FeatureTag: " +
+                          featureTags[i] + " < " + featureTags[i - 1]);
+                return new FeatureListTable(0, new FeatureRecord[0]);
+            }
             featureOffsets[i] = data.readUnsignedShort();
         }
         for (int i = 0; i < featureCount; i++)