8000 Fixed absolute url generation for query strings and hash urls by alexander-schranz · Pull Request #23261 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Fixed absolute url generation for query strings and hash urls #23261

8000 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

Closed

Conversation

alexander-schranz
Copy link
Contributor
@alexander-schranz alexander-schranz commented Jun 22, 2017
Q A
Branch? 2.7, ...
Bug fix? yes
New feature? no
BC breaks? yes? absolute_url will change its output but the old was incorrect
Deprecations? no
Tests pass? yes?
Fixed tickets fixes #23260
License MIT

Fixed absolute url generation for query strings

@stof
8000 Copy link
Member
stof commented Jun 22, 2017

would be great to check if the Link URL resolution in DomCrawler suffers from the same issue

@alexander-schranz
Copy link
Contributor Author

@stoff Looks good there but seems we need to handle # also correctly in the absolute_url. https://github.com/symfony/symfony/blob/master/src/Symfony/Component/DomCrawler/AbstractUriElement.php#L100

@alexander-schranz alexander-schranz changed the title Fixed absolute url generation for query strings Fixed absolute url generation for query strings and hash urls Jun 22, 2017
@alexander-schranz
Copy link
Contributor Author

will change the base to 2.7 think thats the oldest supported version?

@alexander-schranz alexander-schranz changed the base branch from 2.8 to 2.7 June 22, 2017 11:43
@xabbuh xabbuh added this to the 2.7 milestone Jun 22, 2017
@alexander-schranz
Copy link
Contributor Author

I'm not sure why php7 keeps failing on travis

10000
$path = $this->requestContext->getPathInfo().($queryString ? '?'.$queryString : '').$path;
}

if ('?' === $path[0]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can use elseif here and also below?

$path = $request->getRequestUri().$path;
}

if ('?' === $path[0]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

also elseif?


array('http://localhost/foo/bar#baz', '#baz', '/foo/bar'),
array('http://localhost/foo/bar?baz=1#baz', '?baz=1#baz', '/foo/bar?foo=1'),
array('http://localhost/foo/baz?baz=1#baz', 'baz?baz=1#baz', '/foo/bar?foo=1'),
);
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add this test case?

array('http://localhost/foo/bar?0#foo', '#foo', '/foo/bar?0'),

I think your current solution will strip out the existing ?0 query string. I know its an edge case but still 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

test added seems not failing as a 0 as string is true.

Copy link
Contributor

Choose a reason for hiding this comment

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

php -r "var_dump((bool)'0');"

==> bool(false)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dmaicher can you tell me whats wrong with the test as it should fail.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah this is only executed when no current request is given (CLI) and the request context is used instead 😉

So your changes from L 73-79 are currently not covered by tests. You need to add some more test cases into the getGenerateAbsoluteUrlRequestContextData provider 😉

@Tobion
Copy link
Contributor
Tobion commented Jul 5, 2017

👍

@fabpot
Copy link
Member
fabpot commented Jul 6, 2017

Thank you @alexander-schranz.

fabpot added a commit that referenced this pull request Jul 6, 2017
…rls (alexander-schranz)

This PR was squashed before being merged into the 2.7 branch (closes #23261).

Discussion
----------

Fixed absolute url generation for query strings and hash urls

| Q             | A
| ------------- | ---
| Branch?       | 2.7, ...
| Bug fix?      | yes
| New feature?  |no
| BC breaks?    | yes? absolute_url will change its output but the old was incorrect
| Deprecations? |no
| Tests pass?   | yes?
| Fixed tickets | fixes #23260
| License       | MIT

Fixed absolute url generation for query strings

Commits
-------

89ad27d Fixed absolute url generation for query strings and hash urls
@fabpot fabpot closed this Jul 6, 2017
@alexander-schranz alexander-schranz deleted the bugfix/absolute-url branch October 28, 2018 10:04
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.

8 participants
0