Page MenuHomePhabricator

wfAppendQuery urlencodes only when array is passed
Open, Needs TriagePublic

Description

I discovered wfAppendQuery urlencodes passed query only if it is passed as an array (because wfArrayToCgi calls urlencode), but leaves it intact if it is passed as a text. That makes $title->getLocalUrl('page=User talk:Foo') throw an URL that breaks when passed to wikitext's [url description] syntax.

I'm not sure what's the best way to fix. Should we change wfAppendQuery to call urlencode when string is passed (which would require having an inverse function to wfArrayToCgi), or should we remove urlencode from wfArrayToCgi, and change all callers to urlencode themselves?

Event Timeline

I think this is the expected behavior. It's up to the caller to encode the query string. wfAppendQuery() can take a string containing several query parameters (e.g. a=b&c=d), and encoding that would be wrong.

I would just go with the change to messages you proposed.

Thanks @matmarex. My question then would be: Why it used to work?

Did it? I don't think the behavior of any of those functions changed recently…