? Failure

User tests: Successful: Unsuccessful:

avatar jeffda
jeffda
5 Mar 2018

The float and double filter changes the value to an integer if there is no number prior to the decimal.
.0125 => 125
0.0125 => 0.0125

Summary of Changes

Modified the RegExp to look for a leading decimal.

Testing Instructions

Create a form with a float/double filtered text field, and pass a decimal value without a leading number.
Example: .0125

Expected result

The value should remain a decimal like one of the following:
.0125
0.0125

Actual result

The value gets converted to a whole number by removing the decimal and leading zeros.
Example: .0125 becomes 125

avatar jeffda jeffda - open - 5 Mar 2018
avatar jeffda jeffda - change - 5 Mar 2018
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 5 Mar 2018
Category External Library Libraries
avatar brianteeman
brianteeman - comment - 5 Mar 2018

@wilsonge this is a PR against a FoF file - are we accepting those here?

avatar zero-24
zero-24 - comment - 5 Mar 2018

In the last times we did not as this is a external lib maintained outside of the core :-)

avatar wilsonge
wilsonge - comment - 5 Mar 2018

At this point for fof2 it's completely unmaintained by Nic and we've dropped it in Joomla 4 totally it's not so much a third party library. I'll leave it down to @mbabker as release lead to make a decision

avatar franz-wohlkoenig franz-wohlkoenig - change - 19 Apr 2019
Title
Bug Fix: Floats/Doubles Remove Decimal
Floats/Doubles Remove Decimal
avatar franz-wohlkoenig franz-wohlkoenig - edited - 19 Apr 2019
avatar alikon
alikon - comment - 10 May 2019

let's ping @HLeithner then ?

avatar alikon
alikon - comment - 11 May 2019

we have the same issue for example in mod_popular_tags (with or without this patch)

<field
	name="minsize"
	type="number"
	label="MOD_TAGS_POPULAR_FIELD_MINSIZE_LABEL"
        description="MOD_TAGS_POPULAR_FIELD_MINSIZE_DESC"
	default="1"
	filter="float"
/>

for me a fix should be done here https://github.com/joomla/joomla-cms/blob/staging/libraries/src/Filter/InputFilter.php#L196

changing

$pattern = '/[-+]?[0-9]+(\.[0-9]+)?([eE][-+]?[0-9]+)?/';

with

$pattern = '/^(?!-0?(\.0+)?(e|$))-?(0|[1-9]\d*)?(\.\d+)?(?<=\d)(e-?(0|[1-9]\d*))?$/';

but i'm not a regex expert my font of truth is https://stackoverflow.com/questions/2811031/decimal-or-numeric-values-in-regular-expression-validation

here is a list of test case

https://regex101.com/r/fJ7aO0/1

avatar HLeithner
HLeithner - comment - 12 May 2019

Aceppting float without leading zero seams wrong to me.

avatar alikon
alikon - comment - 12 May 2019

ok then simply close it ?

avatar franz-wohlkoenig franz-wohlkoenig - change - 12 May 2019
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2019-05-12 07:28:54
Closed_By franz-wohlkoenig
Labels Removed: J3 Issue
avatar franz-wohlkoenig franz-wohlkoenig - close - 12 May 2019

Add a Comment

Login with GitHub to post a comment