Fix bug in BNF ID validation
This commit is contained in:
@@ -746,11 +746,13 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
|
|||||||
public static function validateBnfId(string $id):string|false {
|
public static function validateBnfId(string $id):string|false {
|
||||||
|
|
||||||
if (!is_numeric(substr($id, -1))) {
|
if (!is_numeric(substr($id, -1))) {
|
||||||
$validation = self::validateNumericId(substr($id, 0, -1), ["https://catalogue.bnf.fr/ark:/12148/cb"]);
|
$id = self::validateNumericId(substr($id, 0, -1), ["https://catalogue.bnf.fr/ark:/12148/cb"]) . substr($id, -1);
|
||||||
}
|
}
|
||||||
else $validation = self::validateNumericId($id, ["https://catalogue.bnf.fr/ark:/12148/cb"]);
|
else $id = self::validateNumericId($id, ["https://catalogue.bnf.fr/ark:/12148/cb"]);
|
||||||
|
|
||||||
if ($validation === false) return false;
|
if ($id === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return $id;
|
return $id;
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,17 @@ final class MDNodaRepositoryTest extends TestCase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data provider for validating BNE IDs.
|
||||||
|
*
|
||||||
|
* @return Generator<string, array{0: string|false, 1: string}>
|
||||||
|
*/
|
||||||
|
public static function bnfIdForValidationProvider():Generator {
|
||||||
|
|
||||||
|
yield "Broken input / duplicate https" => [false, "https://catalogue.bnf.fr/ark:/12148/cbhttps://catalogue.bnf.fr/ark:/12148/cbhttps://catalogue.bnf.fr/ark:/12148/cb104183522"];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensure validating references to the BNE works.
|
* Ensure validating references to the BNE works.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user