From: Happy-melon Date: Wed, 15 Dec 2010 13:33:47 +0000 (+0000) Subject: Better regexes for r78246. X-Git-Tag: 1.31.0-rc.0~33286 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=34d01388656f77e18d4c0db176499632acc737e3;p=lhc%2Fweb%2Fwiklou.git Better regexes for r78246. --- diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index 0d1a77f08b..62aecb0c95 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -1078,7 +1078,7 @@ class HTMLFloatField extends HTMLTextField { # http://dev.w3.org/html5/spec/common-microsyntaxes.html#real-numbers # with the addition that a leading '+' sign is ok. - if ( !preg_match( '/^(\+|\-)?\d+(\.\d+)?(E(\+|\-)?\d+)?$/i', $value ) ) { + if ( !preg_match( '/^((\+|\-)?\d+(\.\d+)?(E(\+|\-)?\d+)?)?$/i', $value ) ) { return wfMsgExt( 'htmlform-float-invalid', 'parse' ); } @@ -1121,7 +1121,7 @@ class HTMLIntField extends HTMLFloatField { # phone numbers when you know that they are integers (the HTML5 type=tel # input does not require its value to be numeric). If you want a tidier # value to, eg, save in the DB, clean it up with intval(). - if ( !preg_match( '/^(\+|\-)?\d*$/', trim( $value ) ) + if ( !preg_match( '/^((\+|\-)?\d+)?$/', trim( $value ) ) ) { return wfMsgExt( 'htmlform-int-invalid', 'parse' ); }