developer.jelix.org is not used any more and exists only for
history. Post new tickets on the Github account.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.
Opened 10 years ago
Closed 10 years ago
#1377 closed enhancement (fixed)
Check plus précis d'un datatypestring
Reported by: | hadrien | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | Jelix 1.2.3 |
Component: | jelix:forms | Version: | 1.2 |
Severity: | normal | Keywords: | jforms |
Cc: | Blocked By: | ||
Blocking: | Documentation needed: | no | |
Hosting Provider: | Php version: |
Description
Lors d'un check d'un datatype String avec un controle sur la longueur de la valeur, il faut compter le nombre de caractères plus précisément. J'ai rajouté un trim et un comptage unique des groupes d'espaces pour éviter qu'il ne soit trop facile de gruger le controle en rajoutant des caractères blancs.
diff basé sur Jelix 1.2
diff --git a/lib/jelix/utils/jDatatype.class.php b/lib/jelix/utils/jDatatype.class.php index ace93e8..27dbec4 100644 --- a/lib/jelix/utils/jDatatype.class.php +++ b/lib/jelix/utils/jDatatype.class.php @@ -87,7 +87,14 @@ class jDatatypeString extends jDatatype { public function check($value){ if($this->hasFacets){ - $len = iconv_strlen($value, $GLOBALS['gJConfig']->charset); + $len = iconv_strlen( + trim( + preg_replace( + '@\s+@', ' ', $value + ) + ), + $GLOBALS['gJConfig']->charset + ); if($this->length !== null && $len != $this->length) return false; if($this->minLength !== null && $len < $this->minLength)
Change History (1)
comment:1 Changed 10 years ago by laurentj
- Resolution set to fixed
- review changed from review? to review+
- Status changed from new to closed
Note: See
TracTickets for help on using
tickets.
Pushed, thanks https://bitbucket.org/jelix/jelix-1.2.x/changeset/3e2fb942e067