-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Fix for 'Uninitialized string offset: 0' when using Request's referer
under PHP 7
#8795
Conversation
Now I like it better. Let me know what do you think 😃 |
Current coverage is 92.89%@@ master #8795 diff @@
==========================================
Files 363 363
Lines 27141 27143 +2
Methods 3206 3206
Messages 0 0
Branches 0 0
==========================================
+ Hits 25212 25214 +2
Misses 1929 1929
Partials 0 0
|
This issue looks similar to the fix done for 2.x 3ad68db That code looks much cleaner. |
Yup, seems exactly the same issue. With If so, let me change it. |
Yes I meant the code in commit I linked :) |
Done :) |
Please squash the commits. |
Sure. BTW, on my first commit I was checking for empty and wasn't necessary. Something like this would be enough: $ref = substr($ref, strlen($base)) ?: '/';
if ($ref[0] !== '/') {
$ref = '/' . $ref;
} pd. I'm squashing |
c826a2b
to
9a3f2a4
Compare
9a3f2a4
to
0de5b1d
Compare
Done :) |
@@ -547,6 +547,9 @@ public function referer($local = false) | |||
if (!empty($ref) && !empty($base)) { | |||
if ($local && strpos($ref, $base) === 0) { | |||
$ref = substr($ref, strlen($base)); | |||
if (empty($ref)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should use strlen()
? empty()
eats '0
'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, you're right. I've changed it in a52a8d1 adding an assertion for it too.
Thanks 👍 |
You're welcome, as always! 😃 |
Fixes #8794
As said in the issue, I'm not sure about how I've fixed it. But let me know what could I change to improve it.