Browse Source

Do not necessarily ignore blank tags in import

We still make them practically impossible in OPML imports, however
tags/0.8.0
J. King 2 months ago
parent
commit
0e95892aea

+ 1
- 0
lib/AbstractException.php View File

@@ -94,6 +94,7 @@ abstract class AbstractException extends \Exception {
"ImportExport/Exception.invalidSemantics" => 10612,
"ImportExport/Exception.invalidFolderName" => 10613,
"ImportExport/Exception.invalidFolderCopy" => 10614,
"ImportExport/Exception.invalidTagName" => 10615,
];

public function __construct(string $msgID = "", $vars = null, \Throwable $e = null) {

+ 2
- 2
lib/ImportExport/AbstractImportExport.php View File

@@ -85,8 +85,8 @@ abstract class AbstractImportExport {
// compile the set of used tags, if this is a new feed or we're doing a full replacement
foreach ($f['tags'] as $t) {
if (!strlen(trim($t))) {
// ignore any blank tags
continue;
// fail if we have any blank tags
throw new Exception("invalidTagName");
}
if (!isset($tagMap[$t])) {
// populate the tag map

+ 4
- 0
lib/ImportExport/OPML.php View File

@@ -61,6 +61,10 @@ class OPML extends AbstractImportExport {
$categories = array_map(function($v) {
return trim(preg_replace("/\s+/", " ", $v));
}, explode(",", $categories));
// filter out any blank categories
$categories = array_filter($categories, function($v) {
return strlen($v);
});
} else {
$categories = [];
}

+ 1
- 0
locale/en.php View File

@@ -163,4 +163,5 @@ return [
'Exception.JKingWeb/Arsse/ImportExport/Exception.invalidSemantics' => 'Input data is not valid {type} data',
'Exception.JKingWeb/Arsse/ImportExport/Exception.invalidFolderName' => 'Input data contains an invalid folder name',
'Exception.JKingWeb/Arsse/ImportExport/Exception.invalidFolderCopy' => 'Input data contains multiple folders of the same name under the same parent',
'Exception.JKingWeb/Arsse/ImportExport/Exception.invalidTagName' => 'Input data contains an invalid tag name',
];

+ 1
- 1
tests/cases/ImportExport/TestOPML.php View File

@@ -135,7 +135,7 @@ OPML_EXPORT_SERIALIZATION;
['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", ""]],
['url' => "", 'title' => "", 'folder' => 0, 'tags' => ["whee", "whoo"]],
], []]],
["FoldersOnly.opml", true, [[], []]],
["FoldersOnly.opml", false, [[], [1 =>

Loading…
Cancel
Save