Fixed a crash in calendar parsing when encountering an illegal VEVENT without newlines.

git-svn-id: https://zxing.googlecode.com/svn/trunk@655 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
dswitkin 2008-10-30 16:35:26 +00:00
parent 1d8b533310
commit bef3c75048
2 changed files with 7 additions and 0 deletions

View file

@ -35,6 +35,10 @@ public final class CalendarParsedResult extends ParsedResult {
String attendee,
String title) {
super(ParsedResultType.CALENDAR);
// Start is required, end is not
if (start == null) {
throw new IllegalArgumentException();
}
validateDate(start);
validateDate(end);
this.summary = summary;

View file

@ -142,6 +142,9 @@ public final class ParsedReaderResultTestCase extends TestCase {
doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504\r\nEND:VEVENT",
ParsedResultType.CALENDAR);
doTestResult("BEGIN:VEVENT\r\nDTEND:20080505T\r\nEND:VEVENT", ParsedResultType.TEXT);
// Make sure illegal entries without newlines don't crash
doTestResult("BEGIN:VEVENTSUMMARY:EventDTSTART:20081030T122030ZDTEND:20081030T132030ZEND:VEVENT",
ParsedResultType.URI);
doTestResult("BEGIN:VEVENT", ParsedResultType.URI); // See above note on why this is URI
}