-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Fixing JFilterInput adding byte offsets to character offset #15966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… an old bug of escapeAttributeValues()
I would be pleased to test, but I do not get the timeout locally on MAMP php 5.4.4 |
@photodude, @PhilETaylor could you make a PR to this PR adding the test case so that we have a prove that this here is working, Thanks |
I have tested this item ✅ successfully on dd82ff2 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/15966. |
And to confirm, you can also use: JRequest::get('request', JREQUEST_ALLOWHTML); with this fix too. Where it previously failed when a field contained the link text above. Same with: Is also working now. Many thanks |
@ggppdk I tested this on my environment trying to save an article in FLEXIcontent and I get the following errors:
followed by error:
Using the same save as before: https://gist.github.com/lyquix-owner/c8c189a016c3d99c1008059920a87787 |
@lyquix-owner did you replace the whole file with the one @ggppdk modified? https://github.com/ggppdk/joomla-cms/blob/dd82ff21aeb1ad70abb1d4ddee4e77e8861d8584/libraries/joomla/filter/input.php which is not a variable field. |
@infograf768 to get the time out you need certain combinations of tags and multibyte characters like Russian, Greek, Arabic, etc. There is a content file in issue #15673 There is a subsection of that content file which has been turned into a unit test at #15810 ( @ggppdk this is the unit test you need to include as mentioned by @rdeutz in #15966 (comment) ) |
Similiar issues with travis
|
@ggppdk you made a mistake in line 1104 '$stringBeforeQuote = substr($attributeValueToEnd, 0, $matches[0][1]);" $attributeValueToEnd isn't set |
libraries/joomla/filter/input.php
Outdated
{ | ||
// We have a closing quote | ||
// We have a closing quote, convert its byte position to a UTF-8 string length, using non-multibyte substr() | ||
$stringBeforeQuote = substr($attributeValueToEnd, 0, $matches[0][1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$attributeValueToEnd
is undefined.... did you mean $attributeValueRemainder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, i meant $attributeValueRemainder, i marginally got some time to make the PR before getting some very much needed sleep, lol
@ggppdk does this fix the escaping case for |
@rdeutz @lyquix-owner @photodude fixed wrong variable name |
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
@PhilETaylor I meant the unit tests, added them to my file locally and tests are failing |
This comment was marked as abuse.
This comment was marked as abuse.
@ggppdk the fixed wrong variable name didn't fix anything. The unit tests now fail to work. |
I have fixed it, i hope unit tests will now pass |
Yes! It worked this time on my end! |
I have tested this item ✅ successfully on 7679cc2 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/15966. |
do we need new tests? |
@infograf768 let some more people test this |
i meant new unit tests |
I can merge @photodude tests, so we have some more testing. The real issue is hard to test because you are in an endless loop |
@infograf768 @rdeutz we need the unit test from #15810 I've been testing this patch and the related unit test on the framework. This seems to solve the issue, but the unit test needs work to be valid. Here are the results from my tests of this patch with #15810 see link https://travis-ci.org/photodude/filter/jobs/231328081 |
I have tested this item ✅ successfully on 7679cc2 after read more 19 février 2017 mélanie propose This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/15966. Edited: 5 lines instead of 4 |
In the above test case, Github skrinked the needed spaces, code available at |
RTC after two successful tests. |
merged it now we can add test cases later |
Pull Request for Issue #15673 , thanks to @csthomas for describing the issue
Summary of Changes
When preg_match() is used with flag: PREG_OFFSET_CAPTURE, the return offsets are in bytes
J3.7.0 made changes to use mult-byte strlen inside Class JFilterInput
-- thus the old code is now broken because it adds character lengths to byte lengths
Solution is to get the substring according to its byte length as provided by preg_match()
and then call multi-byte strlen to get its real character length
Testing Instructions
I can not write now, but someone can contribute, and you can also see the test strings given in the issue (e.g. this one by @tonypartridge
#15673 (comment)
https://github.com/joomla/joomla-cms/files/991337/JFilterInputerCleanMaxExeciutionErrorText.txt
Expected result
With patch form saving (e.g. article edit form) without timeouts (and also unit tests pass ...)
Actual result
Use test strings / examples given above to see the timeout because of inifinite loop in JFilterInput
Documentation Changes Required
None