From 34d01388656f77e18d4c0db176499632acc737e3 Mon Sep 17 00:00:00 2001 From: Happy-melon Date: Wed, 15 Dec 2010 13:33:47 +0000 Subject: [PATCH] Better regexes for r78246. --- includes/HTMLForm.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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' ); } -- 2.20.1