mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 13:12:41 +00:00
Do not necessarily ignore blank tags in import
We still make them practically impossible in OPML imports, however
This commit is contained in:
parent
2aa16f3405
commit
0e95892aea
5 changed files with 9 additions and 3 deletions
|
@ -94,6 +94,7 @@ abstract class AbstractException extends \Exception {
|
||||||
"ImportExport/Exception.invalidSemantics" => 10612,
|
"ImportExport/Exception.invalidSemantics" => 10612,
|
||||||
"ImportExport/Exception.invalidFolderName" => 10613,
|
"ImportExport/Exception.invalidFolderName" => 10613,
|
||||||
"ImportExport/Exception.invalidFolderCopy" => 10614,
|
"ImportExport/Exception.invalidFolderCopy" => 10614,
|
||||||
|
"ImportExport/Exception.invalidTagName" => 10615,
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct(string $msgID = "", $vars = null, \Throwable $e = null) {
|
public function __construct(string $msgID = "", $vars = null, \Throwable $e = null) {
|
||||||
|
|
|
@ -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
|
// compile the set of used tags, if this is a new feed or we're doing a full replacement
|
||||||
foreach ($f['tags'] as $t) {
|
foreach ($f['tags'] as $t) {
|
||||||
if (!strlen(trim($t))) {
|
if (!strlen(trim($t))) {
|
||||||
// ignore any blank tags
|
// fail if we have any blank tags
|
||||||
continue;
|
throw new Exception("invalidTagName");
|
||||||
}
|
}
|
||||||
if (!isset($tagMap[$t])) {
|
if (!isset($tagMap[$t])) {
|
||||||
// populate the tag map
|
// populate the tag map
|
||||||
|
|
|
@ -61,6 +61,10 @@ class OPML extends AbstractImportExport {
|
||||||
$categories = array_map(function($v) {
|
$categories = array_map(function($v) {
|
||||||
return trim(preg_replace("/\s+/", " ", $v));
|
return trim(preg_replace("/\s+/", " ", $v));
|
||||||
}, explode(",", $categories));
|
}, explode(",", $categories));
|
||||||
|
// filter out any blank categories
|
||||||
|
$categories = array_filter($categories, function($v) {
|
||||||
|
return strlen($v);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
$categories = [];
|
$categories = [];
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,4 +163,5 @@ return [
|
||||||
'Exception.JKingWeb/Arsse/ImportExport/Exception.invalidSemantics' => 'Input data is not valid {type} data',
|
'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.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.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',
|
||||||
];
|
];
|
||||||
|
|
|
@ -135,7 +135,7 @@ OPML_EXPORT_SERIALIZATION;
|
||||||
['url' => "http://example.com/3", 'title' => "", 'folder' => 0, 'tags' => []],
|
['url' => "http://example.com/3", 'title' => "", 'folder' => 0, 'tags' => []],
|
||||||
['url' => "http://example.com/4", '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"]],
|
||||||
['url' => "", 'title' => "", 'folder' => 0, 'tags' => ["whee", "whoo", ""]],
|
['url' => "", 'title' => "", 'folder' => 0, 'tags' => ["whee", "whoo"]],
|
||||||
], []]],
|
], []]],
|
||||||
["FoldersOnly.opml", true, [[], []]],
|
["FoldersOnly.opml", true, [[], []]],
|
||||||
["FoldersOnly.opml", false, [[], [1 =>
|
["FoldersOnly.opml", false, [[], [1 =>
|
||||||
|
|
Loading…
Reference in a new issue