Skip to content

[BrowserKit] Update Client::getAbsoluteUri() for query string only URIs #19317

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

Conversation

georaldc
Copy link
Contributor

@georaldc georaldc commented Jul 8, 2016

Q A
Branch? 2.7
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #19303
License MIT
Doc PR -

This PR allows BrowserKit to treat a value containing only query string parameters the same way anchor/hash values are treated when passed as a URI argument to the getAbsoluteUri() method. Helps when encountering sites that force a redirect with a location header value containing only a query string.

Apply same rules to query string only URIs as what's being used for URIs containing only hash/anchor values
@nicolas-grekas
Copy link
Member

👍

@fabpot
Copy link
Member

fabpot commented Jul 10, 2016

Thank you @georaldc.

@fabpot fabpot merged commit 965408f into symfony:2.7 Jul 10, 2016
fabpot added a commit that referenced this pull request Jul 10, 2016
…ing only URIs (georaldc)

This PR was merged into the 2.7 branch.

Discussion
----------

[BrowserKit] Update Client::getAbsoluteUri() for query string only URIs

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #19303
| License       | MIT
| Doc PR        | -

This PR allows BrowserKit to treat a value containing only query string parameters the same way anchor/hash values are treated when passed as a URI argument to the getAbsoluteUri() method. Helps when encountering sites that force a redirect with a location header value containing only a query string.

Commits
-------

965408f Update getAbsoluteUri() for query string uris
if (!$uri || '#' == $uri[0]) {
return preg_replace('/#.*?$/', '', $currentUri).$uri;
// anchor or query string parameters?
if (!$uri || '#' == $uri[0] || '?' == $uri[0]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those both checks should be strict (===).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants