User tests: Successful: Unsuccessful:
Trim search string input fixes #4945
Labels |
Added:
?
|
Status | Pending | ⇒ | Needs Review |
Please fix the following errors:
Thanks!
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/4946.
Personal, I like the the original commit of this PR than the later commit. The reasons is because:
It is sorter and simpler.
I solve the actual problem (just to prevent we include white space in the search string by mistake). Agree that JFilterInput will clean remove the multibyte white spaces. However, for simple use-case like that, I think php native trim function would be enough:
Not sure how other developers think about it.
.
@joomdonation Personally I agree with you. The code looks not nice for such a trivial task.
However I also have to say that it could be done easier in this case. Instead of creating a new method where you have to get the JInput object again, you could just add a line:
$searchstring = $this->_db->quote('%' . $input->getString('searchstring') . '%');
$searchstring = JFilterInput::getInstance()->clean($searchstring, 'TRIM');
@Bakual Agree with your last comment, too. That's what I wanted to say, too. If we want to use JFilterInput, just use the code which you proposed, not creating a new method. Could @bweston92 please update the code as @Bakual proposed ? Then I think we will all be happy :).
@joomdonation @Bakual suggestion doesn't work. Once the percent symbols are around the string it will not trim the white-space within.
The fact I abstracted it into another method is because I didn't want to clutter the code in the search method. Having to do a static call etc is ugly anyhow.
Updated, still don't know why PHP's trim
isn't sufficient.
@bweston92 : Yes, sorry, you are correct. The code @Bakual proposed doesn't work, but it gives the idea how we would like the code looks like if we need to use JFilterInput.
As I mentioned in my first comment, I am OK with use PHP native trim method for this case. Maybe @Bakual can give final decision?
Well the code uses the filter way of things, I think it's had enough commits for a tiny update.
Sorry about the wrong code. I just copy pasted
Updated, still don't know why PHP's trim isn't sufficient.
Thanks. Code looks fine now.
Reason is because it would not work for chines/asian people. It's just better this way and since we recently introduced this new filter it makes sense to use it over trim
.
Ok, merge when you're ready.
Title |
|
||||||
Status | Needs Review | ⇒ | Closed | ||||
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2014-10-29 06:54:40 |
See comment on issues