?
avatar hardiktailored
hardiktailored
12 Aug 2016

Steps to reproduce the issue

Use any existing form or create a form with a text field.
Pass input value mixed with character and integer multiple times like "test123test456" and submit.
Get input value of form field using input filtering method getInt() like below:
$integer = JFactory::getApplication->input->getInt( 'name_of_input_field' );

OR

(1) Open this file of your Joomla: components/com_search/controller.php
(2) Add below line in search() method as first line (Line: 46)
echo $this->input->getInt('searchword', null); die;
(3) Go to front-end of your joomla site and type "test123test456" in Joomla search input.
Above will show the filtered value submitted by search input.

Expected result

Variable should return "123456" as we have filtered integer values only

Actual result

But actually it returns "123" only. Means it returns first integer value occurrence only.

System information (as much as possible)

Joomla! 3.6.3-dev

Additional comments

The problem is in clean() method of libraries/joomla/filter/input.php library file.

I found that preg_match() returns only first occurrence on line no:167 for the input value.

Alternatively we can use pattern like below:
$pattern = '/[^-+0-9]/';

and preg_match() should replace with preg_replace() like below:
$matches = preg_replace($pattern, '', (string) $source);

Same issue I found with UINT case too.

Votes

# of Users Experiencing Issue
1/1
Average Importance Score
3.00

avatar hardiktailored hardiktailored - open - 12 Aug 2016
avatar hardiktailored
hardiktailored - comment - 13 Aug 2016

PR for this issue #11582


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11569.

avatar brianteeman
brianteeman - comment - 13 Aug 2016

Closed as we have a pr for testing see #11582

avatar brianteeman brianteeman - change - 13 Aug 2016
Status New Closed
Closed_Date 0000-00-00 00:00:00 2016-08-13 11:35:15
Closed_By brianteeman
avatar brianteeman brianteeman - close - 13 Aug 2016
avatar hardiktailored
hardiktailored - comment - 13 Aug 2016

@brianteeman the PR link is #11582. Please update PR link in your comment.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11569.

avatar brianteeman
brianteeman - comment - 13 Aug 2016

Oops - done

avatar photodude
photodude - comment - 15 Aug 2016

If this is a big problem, Please also open an issue/PR with the Framework filter package. https://github.com/joomla-framework/filter

(the CMS has some slight differences from the Framework package that it extends from).

avatar photodude
photodude - comment - 15 Aug 2016

@mbabker and or @wilsonge would possibly have insights into why we only match the first int substring.

I'm sure that only matching the first int substring was an intentional design choice. (as evident in the Unit tests)

avatar mbabker
mbabker - comment - 15 Aug 2016

Don't ask me. That API predates me.

On Sunday, August 14, 2016, Walt Sorensen notifications@github.com wrote:

@mbabker https://github.com/mbabker and or @wilsonge
https://github.com/wilsonge would possibly have insights into why we
only match the first int substring.

I'm sure that only match the first int substring was an intentional design
choice. (as evident in the Unit tests)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#11569 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAWfoRPGptKBZuwwFh0P4GsPtTpwiTVCks5qf8fygaJpZM4JjGNj
.

Add a Comment

Login with GitHub to post a comment