Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Controller input strings are URL encoded
judgej
✭
I noticed in Vanilla 2.0.13 (and I assume earlier versions) that strings passed into the controller functions are all URL encoded. Is that intentional? I would have thought all the decoding (which lives in the HTTP layer) would have been done before the data is passed to the controller.
For example, to start a new discussion you can call up page:
However the messages/add controller method is given "Fred+Bloggs" as its value, and the page fails to find the user. Why the "+"? Whether the page is called up using "+", " " or "%20", the controller is given "+" instead of spaces. Similar things happen to other characters that would normally be encoded.
So, is this an oversight, or is it really the intended way Vanilla 2 calls up its controllers? I'm hoping it is a new bug, because it seems bizarre to handle controller input like this.
-- Jason
For example, to start a new discussion you can call up page:
projecttalk/messages/add/Fred Bloggs
However the messages/add controller method is given "Fred+Bloggs" as its value, and the page fails to find the user. Why the "+"? Whether the page is called up using "+", " " or "%20", the controller is given "+" instead of spaces. Similar things happen to other characters that would normally be encoded.
So, is this an oversight, or is it really the intended way Vanilla 2 calls up its controllers? I'm hoping it is a new bug, because it seems bizarre to handle controller input like this.
-- Jason
0
Comments
$this->_ControllerMethodArgs[] = urldecode($Parts[$i]);
Should I raise this as a bug? I am kind of reluctant just to leave it on the bug tracker because it does not look like that is being looked at seriously.
-- Jason
It is how software stacks work - the layers at each end of the stack exchange data, and it matters not what encoding is performed at lower levels to get that data there. I don't believe the main controllers should be decoding HTTP strings any more than they should be unwrapping TCP packets to get at their contents.
I'm sure earlier versions of Vanilla did decode the path components when passing them into the controllers, because stuff that used to work is not working for me now, but I can't see exactly when it changed.
-- Jason
If you try the code with it for a while and don't see anything going wrong we can integrate it in.
Most of the path-based parameters used across the applications and plugins tend to be numeric IDs. Where strings are passed in, they are usually for formatting convenience, but don't actually have a functional use. The "message/add" page is just one of the few examples where it does have a functional use.
So on the whole, it does not look like there will be many - if any - consequences.
One other area that I have had lots of problems with is the image management pages in the profile section. Many of those pages pass around the username as path-based parameters, but never seem to be able to file the users. I am beginning to wonder if this is because of the lack of decoding, since all my usernames have spaces in, but not many other people seem to have this issue, and maybe they don't have spaces in their username. Something for me to explore in the morning anyway.
@Lincoln - I'm curious about what exactly it is that you disagree with?
//edit: And note I'm just answering your question, not debating the point.
Personally I believe the dispatcher *should* handle its input logically and consistently (which is what I am arguing for here), and it is up to developers to decide what data can be passed in a URL. But yes, keeping the URLs clean and simple is something to strive for, but having to store non-encode-required "slugs" for every item that can be accessed by means other than its numeric ID, is a bit of overhead that it would be nice to be able to avoid at times.
https://github.com/vanillaforums/Garden/issues/issue/644