[Pkg-owncloud-commits] [php-sabre-vobject] 42/341: Skip the BOM if exists.
David Prévot
taffit at moszumanska.debian.org
Tue Aug 11 13:35:31 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabre-vobject.
commit fc5b421b033f9bda0110a71a08b04f67f80973eb
Author: Ivan Enderlin <ivan.enderlin at hoa-project.net>
Date: Wed Jan 7 10:29:51 2015 +0100
Skip the BOM if exists.
---
lib/Parser/MimeDir.php | 10 ++++++++++
tests/VObject/ReaderTest.php | 11 +++++++++++
2 files changed, 21 insertions(+)
diff --git a/lib/Parser/MimeDir.php b/lib/Parser/MimeDir.php
index d06b9a2..f12b592 100644
--- a/lib/Parser/MimeDir.php
+++ b/lib/Parser/MimeDir.php
@@ -97,6 +97,16 @@ class MimeDir extends Parser {
protected function parseDocument() {
$line = $this->readLine();
+
+ // BOM is ZERO WIDTH NO-BREAK SPACE (U+FEFF).
+ // It's 0xEF 0xBB 0xBF in UTF-8 hex.
+ if ( 3 <= strlen($line)
+ && ord($line[0]) === 0xef
+ && ord($line[1]) === 0xbb
+ && ord($line[2]) === 0xbf) {
+ $line = substr($line, 3);
+ }
+
switch(strtoupper($line)) {
case 'BEGIN:VCALENDAR' :
$class = isset(VCalendar::$componentMap['VCALENDAR'])
diff --git a/tests/VObject/ReaderTest.php b/tests/VObject/ReaderTest.php
index 9140e5a..2801ee7 100644
--- a/tests/VObject/ReaderTest.php
+++ b/tests/VObject/ReaderTest.php
@@ -435,4 +435,15 @@ ICS;
}
+ public function testReadBOM() {
+
+ $data = "BEGIN:VCALENDAR\r\nEND:VCALENDAR";
+ $result = Reader::read($data);
+
+ $this->assertInstanceOf('Sabre\\VObject\\Component', $result);
+ $this->assertEquals('VCALENDAR', $result->name);
+ $this->assertEquals(0, count($result->children));
+
+ }
+
}
--
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