From: Florent Bruneau Date: Mon, 30 Aug 2010 12:15:32 +0000 (+0200) Subject: Stricter validation of the context of 'mixed' search fields when text X-Git-Tag: xorg/1.0.1~242 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=78be0329bc90988f3a2711af3c0513aa1205834d;p=platal.git Stricter validation of the context of 'mixed' search fields when text version is given. Signed-off-by: Florent Bruneau --- diff --git a/include/ufbuilder.inc.php b/include/ufbuilder.inc.php index 9689155..b95aff0 100644 --- a/include/ufbuilder.inc.php +++ b/include/ufbuilder.inc.php @@ -140,6 +140,18 @@ class UserFilterBuilder return Env::blank($key, $strict); } + public function hasAlnum($key) + { + $str = $this->s($key); + return preg_match('/[a-z0-9]/i', $str); + } + + public function hasAlpha($key) + { + $str = $this->s($key); + return preg_match('/[a-z]/i', $str); + } + public function isOn($key) { return $this->has($key) && $this->t($key) == 'on'; @@ -436,7 +448,7 @@ abstract class UFBF_Mixed extends UFB_Field protected function check(UserFilterBuilder &$ufb) { - if ($ufb->blank($this->envfieldindex) && $ufb->blank($this->envfield)) { + if ($ufb->blank($this->envfieldindex) && !$ufb->hasAlnum($this->envfield)) { $this->empty = true; return true; }