pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1686438 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/TextPosition.java
Date Fri, 19 Jun 2015 15:52:09 GMT
Author: tilman
Date: Fri Jun 19 15:52:09 2015
New Revision: 1686438

URL: http://svn.apache.org/r1686438
Log:
PDFBOX-2831: avoid ArrayIndexOutOfBoundsException if diacritic on ligature

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/TextPosition.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/TextPosition.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/TextPosition.java?rev=1686438&r1=1686437&r2=1686438&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/TextPosition.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/TextPosition.java Fri Jun 19
15:52:09 2015
@@ -19,6 +19,8 @@ package org.apache.pdfbox.text;
 import java.text.Normalizer;
 import java.util.HashMap;
 import java.util.Map;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.pdfbox.pdmodel.font.PDFont;
 import org.apache.pdfbox.util.Matrix;
 
@@ -29,6 +31,8 @@ import org.apache.pdfbox.util.Matrix;
  */
 public final class TextPosition
 {
+    private static final Log LOG = LogFactory.getLog(TextPosition.class);
+
     private static final Map<Integer, String> DIACRITICS = createDiacritics();
 
     // Adds non-decomposing diacritics to the hash with their related combining character.
@@ -529,6 +533,12 @@ public final class TextPosition
 
         for (int i = 0; i < strLen && !wasAdded; i++)
         {
+            if (i >= widths.length)
+            {
+                LOG.info("diacritic " + diacritic.getUnicode() + " on ligature " + unicode
+ 
+                        " is not supported yet and is ignored (PDFBOX-2831)");
+                break;
+            }
             float currCharXEnd = currCharXStart + widths[i];
 
              // this is the case where there is an overlap of the diacritic character with
the



Mime
View raw message