Accept iconclass names with specifying brackets
This commit is contained in:
2 files changed
+14
-13
No files matched your search
@@ -399,26 +399,25 @@ private static function validateNumericId(string $id, array $prefixes):string|fa
|
||||
*/
|
||||
private static function validateIconclassId(string $id):string|false {
|
||||
|
||||
if (filter_var($id, FILTER_VALIDATE_URL) !== false) {
|
||||
$id = rtrim(strtr($id, [
|
||||
'http://iconclass.org/rkd/' => '',
|
||||
'http://iconclass.org/' => '',
|
||||
'https://iconclass.org/' => '',
|
||||
'http://www.iconclass.org/rkd/' => '',
|
||||
'http://www.iconclass.org/' => '',
|
||||
'https://www.iconclass.org/' => '',
|
||||
]), '/');
|
||||
}
|
||||
$id = trim($id, "/");
|
||||
$id = trim(strtr($id, [
|
||||
'http://iconclass.org/rkd/' => '',
|
||||
'http://iconclass.org/' => '',
|
||||
'https://iconclass.org/' => '',
|
||||
'http://www.iconclass.org/rkd/' => '',
|
||||
'http://www.iconclass.org/' => '',
|
||||
'https://www.iconclass.org/' => '',
|
||||
]), '/');
|
||||
|
||||
if (!empty(trim($id, '0123456789abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ(+)'))) {
|
||||
if (!empty(trim($id, '0123456789abcdefghijklmnopqrstuvwxyzäüö-/ABCDEFGHIJKLMNOPQRSTUVWXYZÄÜÖ(+)'))) {
|
||||
// Try url_decoding
|
||||
$id = urldecode($id);
|
||||
if (!empty(trim($id, '0123456789abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ(+)'))) {
|
||||
if (!empty(trim($id, '0123456789abcdefghijklmnopqrstuvwxyzäüö-/ABCDEFGHIJKLMNOPQRSTUVWXYZÄÜÖ(+)'))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_numeric(substr($id, 0, 1))) return false;
|
||||
|
||||
return $id;
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user