Skip to content

Compiled PHP for customized route matching #4343

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
wants to merge 2 commits into from
Closed

Compiled PHP for customized route matching #4343

wants to merge 2 commits into from

Conversation

GeertDD
Copy link
Contributor

@GeertDD GeertDD commented Oct 20, 2014

The second parameter of rtrim() is a character mask. By checking if rtrim($pathinfo, '/contact') === '', $pathinfo could be any URL containing those characters and not only "/contact" which was configured as the route path, for example:

$pathinfo = '/octocat';
var_dump(rtrim($pathinfo, '/contact') === ''); // bool(true)

The second parameter of `rtrim()` is a character mask. By checking if `rtrim($pathinfo, '/contact') === ''`, `$pathinfo` could be any URL containing those characters and not only "/contact" which was configured as the route path, for example:

    $pathinfo = '/octocat';
    var_dump(rtrim($pathinfo, '/contact') === ''); // bool(true)
@@ -822,7 +822,7 @@ variables that are passed into the expression:
Behind the scenes, expressions are compiled down to raw PHP. Our example
would generate the following PHP in the cache directory::

if (rtrim($pathinfo, '/contact') === '' && (
if ('/contact' === $pathinfo && (
Copy link
Member

Choose a reason for hiding this comment

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

it should be: if (0 === strpos($pathinfo, '/_profiler') (since this example is just copied verbatim from the generated cache file)

@GeertDD
Copy link
Contributor Author

GeertDD commented Oct 20, 2014

Fine by me, @wouterj, as long as that erroneous use of rtrim() disappears. Updated to strpos() now.

wouterj added a commit that referenced this pull request Oct 26, 2014
This PR was submitted for the master branch but it was merged into the 2.4 branch instead (closes #4343).

Discussion
----------

Compiled PHP for customized route matching

The second parameter of `rtrim()` is a character mask. By checking if `rtrim($pathinfo, '/contact') === ''`, `$pathinfo` could be any URL containing those characters and not only "/contact" which was configured as the route path, for example:

    $pathinfo = '/octocat';
    var_dump(rtrim($pathinfo, '/contact') === ''); // bool(true)

Commits
-------

fb5e820 Compiled PHP for customized route matching
@wouterj wouterj closed this Oct 26, 2014
@wouterj
Copy link
Member

wouterj commented Oct 26, 2014

I'm sorry, I looked at the wrong code. I've tested the exact routing config of the documentation and it turns out === was indeed used instead of strpos. I've merged your PR and reverted the second commit in 3d88312 Thanks for submitting this fix!

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.

2 participants