Skip to content

Force proper arg separator to avoid composing broken URLs #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2018
Merged

Force proper arg separator to avoid composing broken URLs #98

merged 1 commit into from
May 8, 2018

Conversation

OndraM
Copy link
Contributor

@OndraM OndraM commented May 7, 2018

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Related tickets -
Documentation -
License MIT

What's in this PR?

Make sure http_build_query() uses & as argument separator when assemble query params in URL.

Why?

By default, http_build_query() uses arg_separator.output from php.ini. But this may be set to anything (most often & because of some legacy apps), which will then silently break URLs assembled by the plugin.

For example Guzzle does this as well by default when assembling query strings.

Without the fix this also obviously breaks unit tests when run on our system:

----  broken examples

        Http/Message/Authentication/QueryParam
  29  ! authenticates a request
        method call:
          - withQuery("param1=value1&param2%5B0%5D=value2&userna"...)
        on Double\UriInterface\P34 was not expected, expected calls were:
          - getQuery()
          - withQuery(exact("param1=value1&param2%5B0%5D=value2&username=usern"...))

Checklist

  • Updated CHANGELOG.md to describe BC breaks / deprecations | new feature | bugfix

@dbu dbu merged commit c2a63aa into php-http:master May 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants