-
Bug
-
Resolution: Duplicate
-
Minor
-
None
-
2.1
-
None
-
MOODLE_21_STABLE
-
-
One of our internal systems (not developed internally, it's commercial software circa age of dinosaurs) uses really horrible URLs.
One particular horrible thing about these URLs if that they contain spaces (escaped in URL as +) inside parameter names.
In some parts of our moodle code, we accepted URL from user input (actually from an rss file) and tried to construct a moodle_url to parse it. This fails.
$url = new moodle_url('http://example.org/?test+param=1');
|
print_object($url->out(false));
|
results in
http://example.org/?test_param=1
Note that the + has been changed to an _, whereas it should be either a + or %20. (You get the same result regardless of whether the original URL had + or %20. At least it's consistent.)
I tracked this down in the code and it is caused by the PHP function parse_string which has this behaviour. Most likely this is because parse_string default behaviour is to set php variables which cannot have spaces in the name, however we are using it with the array parameter so it could work, but doesn't.
Fixing this would seem to require either (a) doing a horrible regular expression prior to passing the query string to parse_string, or (b) replacing parse_string with custom code that does the job properly. Both seem quite risky and there are no unit tests for this aspect of moodle_url, so I decided not to try coding it just now, but am filing the bug just in case somebody else feels like it...
- duplicates
-
MDL-29832 moodle_url does not support query params with . in them
-
- Closed
-