LANG-832 FastDateParser does not handle unterminated quotes correctly

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1390795 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2012-09-27 00:55:31 +00:00
parent ad72b9f2bf
commit 65a6458eaa
3 changed files with 9 additions and 0 deletions

View File

@ -22,6 +22,7 @@
<body>
<release version="3.2" date="TBA" description="Next release">
<action issue="LANG-832" type="fix">FastDateParser does not handle unterminated quotes correctly</action>
<action issue="LANG-831" type="fix">FastDateParser does not handle white-space properly</action>
<action issue="LANG-828" type="fix">FastDateParser does not handle non-Gregorian calendars properly</action>
<action issue="LANG-826" type="fix">FastDateParser does not handle non-ASCII digits correctly</action>

View File

@ -141,6 +141,9 @@ public class FastDateParser implements DateParser, Serializable {
currentFormatField= nextFormatField;
currentStrategy= nextStrategy;
}
if (patternMatcher.regionStart() != patternMatcher.regionEnd()) {
throw new IllegalArgumentException("Failed to parse \""+pattern+"\" ; gave up at index "+patternMatcher.regionStart());
}
if(currentStrategy.addRegex(this, regex)) {
collector.add(currentStrategy);
}

View File

@ -333,6 +333,11 @@ public class FastDateParserTest {
assertEquals(cal.getTime(), fdf.parse("'20030210A'B153320989'"));
}
@Test
public void testLANG_832() throws Exception {
testSdfAndFdp("'d'd" ,"d3", false); // OK
testSdfAndFdp("'d'd'","d3", true); // should fail (unterminated quote)
}
@Test
public void testLANG_831() throws Exception {