[Pkg-owncloud-commits] [php-sabre-vobject] 27/38: reject non-vcard data in vcard splitter

David Prévot taffit at moszumanska.debian.org
Tue Sep 23 03:10:23 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch upstream
in repository php-sabre-vobject.

commit 34d60cb751b6ac8958e8ba872c0ba83f2128b111
Author: Dominik Tobschall <dominik at fruux.com>
Date:   Fri Sep 19 10:25:34 2014 +0200

    reject non-vcard data in vcard splitter
---
 lib/Splitter/VCard.php               |  5 +++++
 tests/VObject/Splitter/VCardTest.php | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)

diff --git a/lib/Splitter/VCard.php b/lib/Splitter/VCard.php
index 73af933..7e3687a 100644
--- a/lib/Splitter/VCard.php
+++ b/lib/Splitter/VCard.php
@@ -63,6 +63,11 @@ class VCard implements SplitterInterface {
 
         try {
             $object = $this->parser->parse();
+
+            if (!$object instanceof VObject\Component\VCard) {
+                throw new VObject\ParseException('The supplied input contained non-VCARD data.');
+            }
+
         } catch (VObject\EofException $e) {
             return null;
         }
diff --git a/tests/VObject/Splitter/VCardTest.php b/tests/VObject/Splitter/VCardTest.php
index 093321b..7fa559d 100644
--- a/tests/VObject/Splitter/VCardTest.php
+++ b/tests/VObject/Splitter/VCardTest.php
@@ -33,6 +33,42 @@ EOT;
 
     }
 
+    /**
+     * @expectedException Sabre\VObject\ParseException
+     */
+    function testVCardImportWrongType() {
+        $event[] = <<<EOT
+BEGIN:VEVENT
+UID:foo1
+DTSTAMP:20140122T233226Z
+DTSTART:20140101T050000Z
+END:VEVENT
+EOT;
+
+$event[] = <<<EOT
+BEGIN:VEVENT
+UID:foo2
+DTSTAMP:20140122T233226Z
+DTSTART:20140101T060000Z
+END:VEVENT
+EOT;
+
+        $data = <<<EOT
+BEGIN:VCALENDAR
+$event[0]
+$event[1]
+END:VCALENDAR
+
+EOT;
+        $tempFile = $this->createStream($data);
+
+        $splitter = new VCard($tempFile);
+
+        while($object=$splitter->getNext()) {
+        }
+
+    }
+
     function testVCardImportValidVCardsWithCategories() {
         $data = <<<EOT
 BEGIN:VCARD

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabre-vobject.git



More information about the Pkg-owncloud-commits mailing list