Skip to content

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)
book/routing.rst Outdated
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