Fix the construction of category routes to include the correct layout #20304
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.
This commit fixes a bug where special characters like a semicolon get incorrectly removed from the layout parameter, leading to the url using an invalid layout.
Summary of Changes
Using the
ContentHelperRoute
class to construct a category route can sometimes result in generating an invalid url. Thelayout
parameter has been obtained byJInput::get
which by default will use thecmd
filter, which removes certain special characters from the string.We should use the
string
filter instead here, which allows more characters thancmd
. Note: This does not introduce any security issues as far as I'd assess, because XSS-suspicious strings still get removed by thestring
filter, and other stuff should be catched by url-encoding methods such asJRoute::_
. I might have overseen something though, so if somebody could confirm this I'd be very happy.Testing Instructions
Create a layout with some special characters in it, e.g. a semicolon. This is e.g. being used YOOthemes Warp Framework to split the used layout and the used style from each other.
Then call this method from somewhere and notice that your semicolon has been removed, leading to an incorrect link.
Expected result
The link should contain the correct layout paramater.
Actual result
The link contains a layout parameter with certain special characters removed, leading to an incorrect link as the layout will not be found and the default layout used instead.