#4084 closed defect (bug) (fixed)
add_query_arg urldecodes passed values but doesn't re-encode them.
Reported by: | mdawaffe | Owned by: | rob1n |
---|---|---|---|
Milestone: | 2.2 | Priority: | low |
Severity: | normal | Version: | 2.2 |
Component: | General | Keywords: | has-patch |
Focuses: | Cc: |
Description
It also needs a small tweak regarding the removal of extraneous question marks.
Attachments (2)
Change History (16)
#5
@
18 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
This ticket urlencodes every argument. Perhaps we should only urlencode those arguments that have passed through parse_str? That would keep things as backward compatible as possible.
What we do now (urlencoding everything, even new arguments) makes the most since but is not backward compatible.
For example, there are a few places in core (and surely plugins too) that do:
add_query_arg( 'foo', urlencode($bar), $url );
That is, the arg is manually urlencoded. Those args will probably now get double encoded with the current code in trunk.
So do we go for a function that works like (I think) it seems like it should, or do we go with a less convenient function that preserves backward compatibility?
Related to #4105 (slash behavior)
#6
@
18 years ago
I think preserving backwards compatibility is important. Whenever we try to switch something up on plugin authors (even with tons of warning -- *cough* $table* *cough*) isn't a good idea. Considering history.
As long as it works (double encoding/decoding), then I see no reason to fix it further.
#13
@
18 years ago
Just so you're aware, this did break another useful function of add_query_arg, which was in easily adding arguments to param style arguments, like for wp_list_pages(). I was using it, for example, to quickly append rewrite rule query entries. So, for those who were doing a similar thing and specifically didn't want things urlencoding, the workaround is to rawurlencode the argument you pass to add_query_arg and then urldecode the whole result.
It looks fine. I think we should test this, though. Just to make sure "double encoding" works as we want it to.