🐛 N°8345 - Fix double URL encoding in search URLs #709
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Base information
Symptom (bug)
Symptom only appears on some webservers, it seems to be an edge case. But the cause and fix seem legit.
When trying to open a backoffice URL pointing to a search page, the following error occurs everytime:
It happens when the URL is generated by:
Unfortunately, I can't find a more explicit error message. There is nothing in iTop's nor Apache's error logs. 🫤
Reproduction procedure (bug)
I can't find a reproduction procedure that works everywhere. It only happens on my ionos webserver on which I don't have access to the Apache / PHP configuration. 😭😭😭
P.S: Mind that I patched the badge and dynamic dashlets code in order to verify cause / fix.
Cause (bug)
As this only happens on my ionos webservers (but on all 3 of them, with different iTop instances / versions), I don't know what the system cause is.
Nonetheless, there is a issue with how search URLs are generated in the backoffice. If you look at the
filter
param, you'll see that it is URL encoded twice, hence the 4 hexa characters after the%
.Why is it encoded twice?
\DBSearch::serialize()
rawurlencode($oFilter->serialize())
Changes seem to have been done during the development of the 3.0 and its UI refacto. The complexity of this refacto and its multiple iterations could explain the mixup.
Proposed solution (bug and enhancement)
\DBSearch::serialize()
rawurlencode()
when\DBSearch::serialize()
is used (e.g.rawurlencode($oFilter->serialize())
)Mind that in some places, something like
rawurlencode($oFilter->ToOQL())
is used. It could be replaced by$oFilter->serialize()
for better robustness (Example). I have not made these changes, but I'll be happy to if that what you want.Checklist before requesting a review
Checklist of things to do before PR is ready to merge