User tests: Successful: Unsuccessful:
Pull Request for Issue # .
Changed ReGeX for float filter to accept .25 as float
$in = JApplicationCms::getInstance()->input;
die($in->getFloat('testFloat',0.0));
Navigate to the page and add the $_GET parameter testFloat=.25
Blank page except for the text ".25"
NONE
Status | New | ⇒ | Pending |
Title |
|
Category | ⇒ | Libraries |
Title |
|
Title |
|
Title |
|
Documentation on Floats in PHP
http://php.net/manual/en/language.types.float.php
Formally:
LNUM [0-9]+
DNUM ([0-9]*[\.]{LNUM}) | ({LNUM}[\.][0-9]*)
EXPONENT_DNUM [+-]?(({LNUM} | {DNUM}) [eE][+-]? {LNUM})
Therefore .25
would not match the formal regex for a float in PHP and therefore this PR cannot happen.
Furthermore running PHP code:
var_dump((double).25);
produces
float(0.25)
with a leading zero...
Closed for the reasons stated above
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-01-04 22:15:37 |
Closed_By | ⇒ | brianteeman |
DNUM ([0-9]*[\.]{LNUM}) | ({LNUM}[\.][0-9]*)
(snip)
Therefore.25
would not match the formal regex for a float in PHP and therefore this PR cannot happen.
I don't think you actually tried this. If you had, you would see that [0-9]* allows for an empty space/no zero before the decimal point.
Why are you replying over 2 years on? I have no idea what I tested two years ago!
I would have tested it as stated and also all the unit tests broke too
Oh I see now that you have raised it again, well, nothing to do with me now. If someone else wants to raise a PR for this, that doesnt break all the unit tests, then its up to Joomla to accept or refuse it.
A quick test https://3v4l.org/4RoBX and it seems it would be ok, but heed the warnings of @mbabker and be sure to get a @joomla/security check too.
I would argue that a float
.25
without leading zero before the period is actually a string0.25
would be a float.25
would be a stringThis PR also breaks all the float unit tests and so either this PR or the unit tests need updating.