pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1586751 - in /pdfbox/branches/1.8/pdfbox/src: main/java/org/apache/pdfbox/util/DateConverter.java test/java/org/apache/pdfbox/util/TestDateUtil.java
Date Fri, 11 Apr 2014 19:07:22 GMT
Author: tilman
Date: Fri Apr 11 19:07:22 2014
New Revision: 1586751

URL: http://svn.apache.org/r1586751
Log:
PDFBOX-1803: fix StringIndexOutOfBound on DateConverter.toCalendar as suggested by Eric Leleu

Modified:
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/DateConverter.java
    pdfbox/branches/1.8/pdfbox/src/test/java/org/apache/pdfbox/util/TestDateUtil.java

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/DateConverter.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/DateConverter.java?rev=1586751&r1=1586750&r2=1586751&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/DateConverter.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/DateConverter.java Fri
Apr 11 19:07:22 2014
@@ -773,7 +773,7 @@ public class DateConverter
      */
     public static Calendar toCalendar(String text) throws IOException
     {
-        if (text == null)
+        if (text == null || "".equals(text))
         {
             return null;    
         }

Modified: pdfbox/branches/1.8/pdfbox/src/test/java/org/apache/pdfbox/util/TestDateUtil.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/test/java/org/apache/pdfbox/util/TestDateUtil.java?rev=1586751&r1=1586750&r2=1586751&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/test/java/org/apache/pdfbox/util/TestDateUtil.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/test/java/org/apache/pdfbox/util/TestDateUtil.java Fri
Apr 11 19:07:22 2014
@@ -96,6 +96,12 @@ public class TestDateUtil extends TestCa
         }   
     }
     
+    public void testEmptyDate() throws Exception 
+    {
+       	assertNull(DateConverter.toCalendar(""));
+    	assertNull(DateConverter.toCalendar(new COSString("")));
+    }
+    
     /**
      * Calendar.equals test case.
      * 



Mime
View raw message