From f1a8bb08da8a27e120cea848864e9d3eec814fd3 Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 17 Sep 2018 11:59:37 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B0931:=20Fix=20integrity=20controls=20(tag?= =?UTF-8?q?=20code=20length)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/tagsetfield.class.inc.php | 2 +- dictionaries/en.dictionary.itop.core.php | 2 +- dictionaries/fr.dictionary.itop.core.php | 2 +- test/core/TagSetFieldDataTest.php | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/tagsetfield.class.inc.php b/core/tagsetfield.class.inc.php index 91e39c432..d856f0565 100644 --- a/core/tagsetfield.class.inc.php +++ b/core/tagsetfield.class.inc.php @@ -139,7 +139,7 @@ abstract class TagSetFieldData extends cmdbAbstractObject // Check that code and labels are uniques $sTagCode = $this->Get('tag_code'); // Check tag_code syntax - if (!preg_match("@^[a-zA-Z0-9]{1,20}$@", $sTagCode)) + if (!preg_match("@^[a-zA-Z0-9]{3,20}$@", $sTagCode)) { $this->m_aCheckIssues[] = Dict::S('Core:TagSetFieldData:ErrorTagCodeSyntax'); } diff --git a/dictionaries/en.dictionary.itop.core.php b/dictionaries/en.dictionary.itop.core.php index 1b4c5c7f9..ea4b50088 100644 --- a/dictionaries/en.dictionary.itop.core.php +++ b/dictionaries/en.dictionary.itop.core.php @@ -919,7 +919,7 @@ Dict::Add('EN US', 'English', 'English', array( 'Class:TagSetFieldData+' => '', 'Core:TagSetFieldData:ErrorDeleteUsedTag' => 'Used tags cannot be deleted', 'Core:TagSetFieldData:ErrorDuplicateTagCodeOrLabel' => 'Tags codes or labels must be unique', - 'Core:TagSetFieldData:ErrorTagCodeSyntax' => 'Tags code should match [a-zA-Z0-9]{1,20} syntax', + 'Core:TagSetFieldData:ErrorTagCodeSyntax' => 'Tags code should contain between 3 and 20 alphanumeric characters', 'Core:TagSetFieldData:ErrorTagLabelSyntax' => 'Tags label should not contain | nor be empty', 'Core:TagSetFieldData:ErrorCodeUpdateNotAllowed' => 'Tags code cannot be changed', )); diff --git a/dictionaries/fr.dictionary.itop.core.php b/dictionaries/fr.dictionary.itop.core.php index 34e2b7df7..c62ce845f 100644 --- a/dictionaries/fr.dictionary.itop.core.php +++ b/dictionaries/fr.dictionary.itop.core.php @@ -767,7 +767,7 @@ Opérateurs :
'Core:Validator:MustSelectOne' => 'Veuillez choisir une valeur', 'Core:TagSetFieldData:ErrorDeleteUsedTag' => 'Impossible de supprimer une étiquette utilisée', 'Core:TagSetFieldData:ErrorDuplicateTagCodeOrLabel' => 'Les codes et noms des étiquettes doivent être unique', - 'Core:TagSetFieldData:ErrorTagCodeSyntax' => 'Le code de l\'étiquette doit avoir la syntaxe suivante : [a-zA-Z0-9]{1,20}', + 'Core:TagSetFieldData:ErrorTagCodeSyntax' => 'Le code de l\'étiquette doit contenir entre 3 et 20 caractères alphanumériques.', 'Core:TagSetFieldData:ErrorTagLabelSyntax' => 'Le nom de l\'étiquette ne doit pas être vide ni contenir le caractère \'|\'', 'Core:TagSetFieldData:ErrorCodeUpdateNotAllowed' => 'Le code de l\'étiquette ne peut pas être changé', )); diff --git a/test/core/TagSetFieldDataTest.php b/test/core/TagSetFieldDataTest.php index 8adedbbff..a0dc514b3 100644 --- a/test/core/TagSetFieldDataTest.php +++ b/test/core/TagSetFieldDataTest.php @@ -165,7 +165,9 @@ class TagSetFieldDataTest extends ItopDataTestCase 'No -' => array('tag-1'), 'No %' => array('tag%1'), 'Less than 21 chars' => array('012345678901234567890'), - 'At least one char' => array(''), + 'At least 3 chars' => array(''), + 'At least 3 chars 1' => array('a'), + 'At least 3 chars 2' => array('ab'), 'No #' => array('#tag'), 'No !' => array('tag!'), );