Skip to content
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

[Routing] fix absolute url generation when scheme is not known #32000

Merged
merged 1 commit into from Jun 13, 2019

Conversation

Tobion
Copy link
Member

@Tobion Tobion commented Jun 12, 2019

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

This fixes two edge cases in the url generator:

  1. when the context scheme is not known (empty) generating an absolute url would return an invalid url starting with ://host/path. [Routing] Use the default host even if context is empty #25491 handled the case when the host is unknown which makes sense. but the way it was done, created this new problem.
  2. non-http(s) urls do not require a host. e.g. typical file:///path urls. url generator is fixed to be in line with rfc3986

}

public function testDefaultHostIsUsedWhenContextHostIsEmptyAndSchemeIsNot()
Copy link
Member Author

@Tobion Tobion Jun 12, 2019

Choose a reason for hiding this comment

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

that test was the same as the one above because a RequestContext has a default scheme. I changed it slightly to handle a different case.

@Tobion Tobion force-pushed the url-generator-wihout-scheme branch from 4fc4817 to 8e04222 Compare June 12, 2019 01:24
@nicolas-grekas nicolas-grekas added this to the 3.4 milestone Jun 12, 2019
@fabpot
Copy link
Member

fabpot commented Jun 13, 2019

Thank you @Tobion.

@fabpot fabpot merged commit 8e04222 into symfony:3.4 Jun 13, 2019
fabpot added a commit that referenced this pull request Jun 13, 2019
…nown (Tobion)

This PR was merged into the 3.4 branch.

Discussion
----------

[Routing] fix absolute url generation when scheme is not known

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #25491
| License       | MIT
| Doc PR        |

This fixes two edge cases in the url generator:
1. when the context scheme is not known (empty) generating an absolute url would return an invalid url starting with `://host/path`. #25491 handled the case when the host is unknown which makes sense. but the way it was done, created this new problem.
2. non-http(s) urls do not require a host. e.g. typical `file:///path` urls. url generator is fixed to be in line with rfc3986

Commits
-------

8e04222 [Routing] fix absolute url generation when scheme is not known
@Tobion Tobion deleted the url-generator-wihout-scheme branch June 14, 2019 12:02
This was referenced Jun 26, 2019
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.

None yet

4 participants