Handle VEVENT with malformed GEO

This commit is contained in:
Sean Owen 2014-02-22 13:06:32 +00:00
parent 1b898320ac
commit c77b79d690
2 changed files with 13 additions and 0 deletions

View file

@ -62,6 +62,9 @@ public final class VEventResultParser extends ResultParser {
longitude = Double.NaN; longitude = Double.NaN;
} else { } else {
int semicolon = geoString.indexOf(';'); int semicolon = geoString.indexOf(';');
if (semicolon < 0) {
return null;
}
try { try {
latitude = Double.parseDouble(geoString.substring(0, semicolon)); latitude = Double.parseDouble(geoString.substring(0, semicolon));
longitude = Double.parseDouble(geoString.substring(semicolon + 1)); longitude = Double.parseDouble(geoString.substring(semicolon + 1));

View file

@ -138,6 +138,16 @@ public final class CalendarParsedResultTestCase extends Assert {
null, null, null, "20080504T123456Z", null, null, null, -12.345, -45.678); null, null, null, "20080504T123456Z", null, null, null, -12.345, -45.678);
} }
@Test
public void testBadGeo() {
// Not parsed as VEVENT
Result fakeResult = new Result("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" +
"GEO:-12.345\r\n" +
"END:VEVENT\r\nEND:VCALENDAR", null, null, BarcodeFormat.QR_CODE);
ParsedResult result = ResultParser.parseResult(fakeResult);
assertSame(ParsedResultType.URI, result.getType());
}
@Test @Test
public void testOrganizer() { public void testOrganizer() {
doTest( doTest(