Accept iconclass names with specifying brackets
This commit is contained in:
@@ -399,26 +399,25 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
|
|||||||
*/
|
*/
|
||||||
private static function validateIconclassId(string $id):string|false {
|
private static function validateIconclassId(string $id):string|false {
|
||||||
|
|
||||||
if (filter_var($id, FILTER_VALIDATE_URL) !== false) {
|
$id = trim(strtr($id, [
|
||||||
$id = rtrim(strtr($id, [
|
'http://iconclass.org/rkd/' => '',
|
||||||
'http://iconclass.org/rkd/' => '',
|
'http://iconclass.org/' => '',
|
||||||
'http://iconclass.org/' => '',
|
'https://iconclass.org/' => '',
|
||||||
'https://iconclass.org/' => '',
|
'http://www.iconclass.org/rkd/' => '',
|
||||||
'http://www.iconclass.org/rkd/' => '',
|
'http://www.iconclass.org/' => '',
|
||||||
'http://www.iconclass.org/' => '',
|
'https://www.iconclass.org/' => '',
|
||||||
'https://www.iconclass.org/' => '',
|
]), '/');
|
||||||
]), '/');
|
|
||||||
}
|
|
||||||
$id = trim($id, "/");
|
|
||||||
|
|
||||||
if (!empty(trim($id, '0123456789abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ(+)'))) {
|
if (!empty(trim($id, '0123456789abcdefghijklmnopqrstuvwxyzäüö-/ABCDEFGHIJKLMNOPQRSTUVWXYZÄÜÖ(+)'))) {
|
||||||
// Try url_decoding
|
// Try url_decoding
|
||||||
$id = urldecode($id);
|
$id = urldecode($id);
|
||||||
if (!empty(trim($id, '0123456789abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ(+)'))) {
|
if (!empty(trim($id, '0123456789abcdefghijklmnopqrstuvwxyzäüö-/ABCDEFGHIJKLMNOPQRSTUVWXYZÄÜÖ(+)'))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_numeric(substr($id, 0, 1))) return false;
|
||||||
|
|
||||||
return $id;
|
return $id;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -415,6 +415,8 @@ final class MDNodaRepositoryTest extends TestCase {
|
|||||||
yield "45C221 ; ID" => ["45C221", "45C221"];
|
yield "45C221 ; ID" => ["45C221", "45C221"];
|
||||||
yield "45C221(+321) ; ID" => ["45C221(+321)", "45C221(+321)"];
|
yield "45C221(+321) ; ID" => ["45C221(+321)", "45C221(+321)"];
|
||||||
yield "45C221(%2B321) > 45C221(+321) ; ID" => ["45C221(+321)", "45C221(%2B321)"];
|
yield "45C221(%2B321) > 45C221(+321) ; ID" => ["45C221(+321)", "45C221(%2B321)"];
|
||||||
|
yield "82A(Rattenfanger) ; ID" => ["82A(Rattenfanger)", "http://iconclass.org/rkd/82A(Rattenfanger)"];
|
||||||
|
yield "82A(Rattenfänger) ; ID" => ["82A(Rattenfänger)", "http://iconclass.org/rkd/82A(Rattenfänger)"];
|
||||||
yield "Broken input / adfdasjfklasäj%l" => [false, "adfdasjfklasäj%l"];
|
yield "Broken input / adfdasjfklasäj%l" => [false, "adfdasjfklasäj%l"];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user