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

[5.1] Fix improper use of mb_substr() #16081

Merged
merged 1 commit into from
Oct 24, 2016
Merged

[5.1] Fix improper use of mb_substr() #16081

merged 1 commit into from
Oct 24, 2016

Conversation

vlakoff
Copy link
Contributor

@vlakoff vlakoff commented Oct 24, 2016

Follow-up to #10894.
Because strpos($path, '?') is single-byte, the subsequent substr() have to be single-byte as well.

  • url('ééé/ààà?ùùù', 'extra');
    • http://example.org/ééé/ààà/extra?ùùù – expected
    • http://example.org/ééé/ààà?ùùù/extra – result
  • url('ééé?ààà?ùùù', 'extra');
    • http://example.org/ééé/extra?ààà?ùùù – expected
    • http://example.org/ééé?àà/extraà?ùùù – result


ping @rkgrep :)

@vlakoff
Copy link
Contributor Author

vlakoff commented Oct 24, 2016

In case you would be interested, the following implementation is about 65% faster (10000 iterations: from 147 ms to 51 ms), and imho clearer:

if (strpos($path, '?') !== false) {
    $parts = explode('?', $path, 2);
    $path = $parts[0];
    $query = '?'.$parts[1];
} else {
    $query = '';
}

@taylorotwell taylorotwell merged commit 810311e into laravel:5.1 Oct 24, 2016
@vlakoff vlakoff deleted the url branch October 24, 2016 22:16
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