diff options
-rw-r--r-- | application/NetscapeBookmarkUtils.php | 4 | ||||
-rw-r--r-- | tests/NetscapeBookmarkUtils/BookmarkImportTest.php | 15 | ||||
-rw-r--r-- | tests/NetscapeBookmarkUtils/input/lowercase_doctype.htm | 8 |
3 files changed, 25 insertions, 2 deletions
diff --git a/application/NetscapeBookmarkUtils.php b/application/NetscapeBookmarkUtils.php index dd7057f8..2aa2da3b 100644 --- a/application/NetscapeBookmarkUtils.php +++ b/application/NetscapeBookmarkUtils.php | |||
@@ -108,7 +108,7 @@ class NetscapeBookmarkUtils | |||
108 | $filesize = $files['filetoupload']['size']; | 108 | $filesize = $files['filetoupload']['size']; |
109 | $data = file_get_contents($files['filetoupload']['tmp_name']); | 109 | $data = file_get_contents($files['filetoupload']['tmp_name']); |
110 | 110 | ||
111 | if (strpos($data, '<!DOCTYPE NETSCAPE-Bookmark-file-1>') === false) { | 111 | if (preg_match('/<!DOCTYPE NETSCAPE-Bookmark-file-1>/i', $data) === 0) { |
112 | return self::importStatus($filename, $filesize); | 112 | return self::importStatus($filename, $filesize); |
113 | } | 113 | } |
114 | 114 | ||
@@ -160,7 +160,7 @@ class NetscapeBookmarkUtils | |||
160 | } else if ($post['privacy'] == 'public') { | 160 | } else if ($post['privacy'] == 'public') { |
161 | // all imported links are public | 161 | // all imported links are public |
162 | $private = 0; | 162 | $private = 0; |
163 | } | 163 | } |
164 | 164 | ||
165 | $newLink = array( | 165 | $newLink = array( |
166 | 'title' => $bkm['title'], | 166 | 'title' => $bkm['title'], |
diff --git a/tests/NetscapeBookmarkUtils/BookmarkImportTest.php b/tests/NetscapeBookmarkUtils/BookmarkImportTest.php index 4961aa2c..f0a958cb 100644 --- a/tests/NetscapeBookmarkUtils/BookmarkImportTest.php +++ b/tests/NetscapeBookmarkUtils/BookmarkImportTest.php | |||
@@ -127,6 +127,21 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
127 | } | 127 | } |
128 | 128 | ||
129 | /** | 129 | /** |
130 | * Attempt to import bookmarks from a file with a lowercase Doctype | ||
131 | */ | ||
132 | public function testImportLowecaseDoctype() | ||
133 | { | ||
134 | $files = file2array('lowercase_doctype.htm'); | ||
135 | $this->assertStringMatchesFormat( | ||
136 | 'File lowercase_doctype.htm (386 bytes) was successfully processed in %d seconds:' | ||
137 | .' 2 links imported, 0 links overwritten, 0 links skipped.', | ||
138 | NetscapeBookmarkUtils::import(null, $files, $this->linkDb, $this->conf, $this->history) | ||
139 | ); | ||
140 | $this->assertEquals(2, count($this->linkDb)); | ||
141 | } | ||
142 | |||
143 | |||
144 | /** | ||
130 | * Ensure IE dumps are supported | 145 | * Ensure IE dumps are supported |
131 | */ | 146 | */ |
132 | public function testImportInternetExplorerEncoding() | 147 | public function testImportInternetExplorerEncoding() |
diff --git a/tests/NetscapeBookmarkUtils/input/lowercase_doctype.htm b/tests/NetscapeBookmarkUtils/input/lowercase_doctype.htm new file mode 100644 index 00000000..8911ad19 --- /dev/null +++ b/tests/NetscapeBookmarkUtils/input/lowercase_doctype.htm | |||
@@ -0,0 +1,8 @@ | |||
1 | <!DOCTYPE netscape-bookmark-file-1> | ||
2 | <TITLE>Bookmarks</TITLE> | ||
3 | <H1>Bookmarks</H1> | ||
4 | <DL><p> | ||
5 | <DT><A HREF="https://private.tld" ADD_DATE="10/Oct/2000:13:55:36 +0300" PRIVATE="1" TAGS="private secret">Secret stuff</A> | ||
6 | <DD>Super-secret stuff you're not supposed to know about | ||
7 | <DT><A HREF="http://public.tld" ADD_DATE="1456433748" PRIVATE="0" TAGS="public hello world">Public stuff</A> | ||
8 | </DL><p> | ||