Merge pull request #635 from virtualtam/fix/import/ie
Fix: ensure Internet Explorer bookmark dumps can be imported
This commit is contained in:
commit
f396134bf1
3 changed files with 38 additions and 2 deletions
|
@ -98,8 +98,7 @@ public static function import($post, $files, $linkDb, $pagecache)
|
|||
$filesize = $files['filetoupload']['size'];
|
||||
$data = file_get_contents($files['filetoupload']['tmp_name']);
|
||||
|
||||
// Sniff file type
|
||||
if (! startsWith($data, '<!DOCTYPE NETSCAPE-Bookmark-file-1>')) {
|
||||
if (strpos($data, '<!DOCTYPE NETSCAPE-Bookmark-file-1>') === false) {
|
||||
return self::importStatus($filename, $filesize);
|
||||
}
|
||||
|
||||
|
|
|
@ -82,6 +82,34 @@ public function testImportNoDoctype()
|
|||
$this->assertEquals(0, count($this->linkDb));
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure IE dumps are supported
|
||||
*/
|
||||
public function testImportInternetExplorerEncoding()
|
||||
{
|
||||
$files = file2array('internet_explorer_encoding.htm');
|
||||
$this->assertEquals(
|
||||
'File internet_explorer_encoding.htm (356 bytes) was successfully processed:'
|
||||
.' 1 links imported, 0 links overwritten, 0 links skipped.',
|
||||
NetscapeBookmarkUtils::import(array(), $files, $this->linkDb, $this->pagecache)
|
||||
);
|
||||
$this->assertEquals(1, count($this->linkDb));
|
||||
$this->assertEquals(0, count_private($this->linkDb));
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
'linkdate' => '20160618_173944',
|
||||
'title' => 'Hg Init a Mercurial tutorial by Joel Spolsky',
|
||||
'url' => 'http://hginit.com/',
|
||||
'description' => '',
|
||||
'private' => 0,
|
||||
'tags' => ''
|
||||
),
|
||||
$this->linkDb->getLinkFromUrl('http://hginit.com/')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Import bookmarks nested in a folder hierarchy
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<!DOCTYPE NETSCAPE-Bookmark-file-1>
|
||||
<!-- This is an automatically generated file.
|
||||
It will be read and overwritten.
|
||||
Do Not Edit! -->
|
||||
<TITLE>Bookmarks</TITLE>
|
||||
<H1>Bookmarks</H1>
|
||||
<DL><p>
|
||||
<DT><A HREF="http://hginit.com/" ADD_DATE="1466271584" LAST_VISIT="1466271584" LAST_MODIFIED="1466271584" >Hg Init a Mercurial tutorial by Joel Spolsky</A>
|
||||
</DL><p>
|
Loading…
Reference in a new issue