diff --git a/lib/ImportExport/OPML.php b/lib/ImportExport/OPML.php index ca02f2d..7328413 100644 --- a/lib/ImportExport/OPML.php +++ b/lib/ImportExport/OPML.php @@ -158,7 +158,7 @@ class OPML { $folderMap[$body] = sizeof($folderMap); // iterate through each node in the body $node = $body->firstChild; - while ($node && $node != $body) { + while ($node && !$node->isSameNode($body)) { if ($node->nodeType == \XML_ELEMENT_NODE && $node->nodeName === "outline") { // process any nodes which are outlines if ($node->getAttribute("type") === "rss") { @@ -170,7 +170,7 @@ class OPML { if (strlen($categories)) { // collapse and trim whitespace from category names, if any, splitting along commas $categories = array_map(function($v) { - return trim(preg_replace("/\s+/g", " ", $v)); + return trim(preg_replace("/\s+/", " ", $v)); }, explode(",", $categories)); } else { $categories = []; diff --git a/tests/cases/ImportExport/TestOPML.php b/tests/cases/ImportExport/TestOPML.php index 3390444..94d1b05 100644 --- a/tests/cases/ImportExport/TestOPML.php +++ b/tests/cases/ImportExport/TestOPML.php @@ -128,6 +128,44 @@ OPML_EXPORT_SERIALIZATION; ["Empty.1.opml", false, [[], []]], ["Empty.2.opml", false, [[], []]], ["Empty.3.opml", false, [[], []]], + ["FeedsOnly.opml", false, [[ + [ + 'url' => "http://example.com/1", + 'title' => "Feed 1", + 'folder' => 0, + 'tags' => [], + ], + [ + 'url' => "http://example.com/2", + 'title' => "", + 'folder' => 0, + 'tags' => [], + ], + [ + 'url' => "http://example.com/3", + 'title' => "", + 'folder' => 0, + 'tags' => [], + ], + [ + 'url' => "http://example.com/4", + 'title' => "", + 'folder' => 0, + 'tags' => [], + ], + [ + 'url' => "", + 'title' => "", + 'folder' => 0, + 'tags' => ["whee"], + ], + [ + 'url' => "", + 'title' => "", + 'folder' => 0, + 'tags' => ["whee", "whoo", ""], + ], + ], []]], ]; } } diff --git a/tests/docroot/Import/OPML/FeedsOnly.opml b/tests/docroot/Import/OPML/FeedsOnly.opml new file mode 100644 index 0000000..4e68260 --- /dev/null +++ b/tests/docroot/Import/OPML/FeedsOnly.opml @@ -0,0 +1,12 @@ + + + + + + + + + + + +