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 URL generation with look-around requirements #27601

Merged
merged 1 commit into from Feb 21, 2019

Conversation

nasimnabavi
Copy link
Contributor

Q A
Branch? 2.8 up to 4.1 for bug fixes
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #10548
License MIT
Doc PR

If you have a non-catchable pattern in requirements like f.e. a positive lookahead (.+(?=/foo/)), the generator will not accept the parameter as the parameter itself cannot fulfil the requirement, but only matches in the context of the entire path.
This fix looks for lookAround in the path and ignores checking the requirements if any lookAround exists.

@nicolas-grekas
Copy link
Member

ping @schmittjoh since you had some interest into these also.

@schmittjoh
Copy link
Contributor

@nicolas-grekas , yeah, this is actually a pull-request from us.

I've talked with Nasim, and she has suggested a slightly different fix now. Instead of turning off the validation entirely for the variable, we just remove validation of the look-around parts. This has the advantage that the value itself is still validated.

@nicolas-grekas nicolas-grekas added this to the 2.8 milestone Jun 15, 2018
@nasimnabavi
Copy link
Contributor Author

Comments are applied:

  • regEx is changed.
  • new test added

@fabpot
Copy link
Member

fabpot commented Oct 10, 2018

@nicolas-grekas @stof Ready for another review of this PR?

@stof
Copy link
Member

stof commented Oct 10, 2018

From a performance PoV, I think it would be better to perform this regex transformation at compile time, by adding a new (optional) index in the token (if it is not there, we would use the unmodified pattern). But this would probably require doing that change in master only, considering it as a new feature (which could be fine. the original issue #10548 was tagged as an enhancement, not as a bug).

@nicolas-grekas nicolas-grekas changed the title [Routing] lookAhead fixed [Routing] fix URL generation with look-ahead requirements Nov 25, 2018
@nicolas-grekas nicolas-grekas changed the title [Routing] fix URL generation with look-ahead requirements [Routing] fix URL generation with look-around requirements Nov 25, 2018
@nicolas-grekas nicolas-grekas force-pushed the ticket_10548 branch 3 times, most recently from 9aa09e1 to 4042e1b Compare November 25, 2018 09:52
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

I just pushed some minor changes (many strpos() are slower than a direct preg_replace() so I inlined the call). Let's merge this in 3.4: the perf impact is negligible (PCRE is fast as hell). Not worth a new token in master IMHO.

@nicolas-grekas nicolas-grekas modified the milestones: 2.8, 3.4 Nov 26, 2018
@nicolas-grekas nicolas-grekas force-pushed the ticket_10548 branch 2 times, most recently from 578eb1b to 1e9c795 Compare November 26, 2018 13:31
@fabpot
Copy link
Member

fabpot commented Feb 21, 2019

Thank you @nasimnabavi.

@fabpot fabpot merged commit c474451 into symfony:3.4 Feb 21, 2019
fabpot added a commit that referenced this pull request Feb 21, 2019
… (nasimnabavi)

This PR was merged into the 3.4 branch.

Discussion
----------

[Routing] fix URL generation with look-around requirements

| Q             | A
| ------------- | ---
| Branch?       | 2.8 up to 4.1 for bug fixes
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #10548
| License       | MIT
| Doc PR        |

If you have a non-catchable pattern in requirements like f.e. a positive lookahead (.+(?=/foo/)), the generator will not accept the parameter as the parameter itself cannot fulfil the requirement, but only matches in the context of the entire path.
This fix looks for lookAround in the path and ignores checking the requirements if any lookAround exists.

Commits
-------

c474451 [Routing] fix URL generation with look-around requirements
This was referenced Mar 3, 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

7 participants