You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2014/03/03 22:44:16 UTC

svn commit: r1573770 - in /commons/proper/lang/trunk/src: changes/changes.xml main/java/org/apache/commons/lang3/time/DurationFormatUtils.java test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java

Author: sebb
Date: Mon Mar  3 21:44:15 2014
New Revision: 1573770

URL: http://svn.apache.org/r1573770
Log:
LANG-981 DurationFormatUtils#lexx does not detect unmatched quote char

Modified:
    commons/proper/lang/trunk/src/changes/changes.xml
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java

Modified: commons/proper/lang/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/changes/changes.xml?rev=1573770&r1=1573769&r2=1573770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/changes/changes.xml [utf-8] (original)
+++ commons/proper/lang/trunk/src/changes/changes.xml [utf-8] Mon Mar  3 21:44:15 2014
@@ -22,6 +22,7 @@
   <body>
 
   <release version="3.4" date="TBA" description="TBA">
+    <action issue="LANG-981" type="fix" dev="sebb">DurationFormatUtils#lexx does not detect unmatched quote char</action>
     <action issue="LANG-984" type="fix" dev="sebb">DurationFormatUtils does not handle large durations correctly</action>
     <action issue="LANG-982" type="fix" dev="sebb">DurationFormatUtils.formatDuration(61999, "s.SSSS") - ms field size should be 4 digits</action>
     <action issue="LANG-978" type="fix" dev="sebb">Failing tests with Java 8 b128</action>

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java?rev=1573770&r1=1573769&r2=1573770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java Mon Mar  3 21:44:15 2014
@@ -542,6 +542,9 @@ public class DurationFormatUtils {
                 buffer = null;
             }
         }
+        if (inLiteral) { // i.e. we have not found the end of the literal
+            throw new IllegalArgumentException("Unmatched quote in format: " + format);
+        }
         return list.toArray(new Token[list.size()]);
     }
 

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java?rev=1573770&r1=1573769&r2=1573770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java Mon Mar  3 21:44:15 2014
@@ -553,7 +553,12 @@ public class DurationFormatUtilsTest {
         bruteForce(1969, 1, 28, "M", Calendar.MONTH);  // tests for 48 years
         //bruteForce(1996, 1, 29, "M", Calendar.MONTH);  // this will fail
     }
-    
+
+    @Test(expected=IllegalArgumentException.class)
+    public void testLANG981() { // unmatched quote char in lexx
+        DurationFormatUtils.lexx("'yMdHms''S");
+    }
+
     private static final int FOUR_YEARS = 365 * 3 + 366;
     
     // Takes a minute to run, so generally turned off