Issue 439: be more lax and don't look for END
[zxing.git] / core / src / com / google / zxing / client / result / VEventResultParser.java
index 188e2d0..2dd3ac6 100644 (file)
@@ -20,9 +20,9 @@ import com.google.zxing.Result;
 
 /**
  * Partially implements the iCalendar format's "VEVENT" format for specifying a
- * calendar event. See RFC 2445. This supports SUMMARY, DTSTART and DTEND fields.
+ * calendar event. See RFC 2445. This supports SUMMARY, LOCATION, DTSTART and DTEND fields.
  *
- * @author srowen@google.com (Sean Owen)
+ * @author Sean Owen
  */
 final class VEventResultParser extends ResultParser {
 
@@ -35,17 +35,17 @@ final class VEventResultParser extends ResultParser {
       return null;
     }
     int vEventStart = rawText.indexOf("BEGIN:VEVENT");
-    int vEventEnd = rawText.indexOf("END:VEVENT");
-    if (vEventStart < 0 || vEventEnd < 0) {
+    if (vEventStart < 0) {
       return null;
     }
-    rawText = rawText.substring(vEventStart + 14, vEventEnd); // skip over BEGIN:VEVENT\r\n at start
 
-    String summary = VCardResultParser.matchSingleVCardPrefixedField("SUMMARY", rawText);
-    String start = VCardResultParser.matchSingleVCardPrefixedField("DTSTART", rawText);
-    String end = VCardResultParser.matchSingleVCardPrefixedField("DTEND", rawText);
+    String summary = VCardResultParser.matchSingleVCardPrefixedField("SUMMARY", rawText, true);
+    String start = VCardResultParser.matchSingleVCardPrefixedField("DTSTART", rawText, true);
+    String end = VCardResultParser.matchSingleVCardPrefixedField("DTEND", rawText, true);
+    String location = VCardResultParser.matchSingleVCardPrefixedField("LOCATION", rawText, true);
+    String description = VCardResultParser.matchSingleVCardPrefixedField("DESCRIPTION", rawText, true);
     try {
-      return new CalendarParsedResult(summary, start, end, null, null, null);
+      return new CalendarParsedResult(summary, start, end, location, null, description);
     } catch (IllegalArgumentException iae) {
       return null;
     }