-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Allow empty needles in mbstring functions #4977
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
Conversation
I think this is just causing the underlying C lib to return an error code which is transmitted via the normal FALSE return. |
Right, the mbfl code will also need to be adjusted: php-src/ext/mbstring/libmbfl/mbfl/mbfilter.c Lines 858 to 861 in 1d69bf1
|
It seems to me that would need more adjustments, e.g. php-src/ext/mbstring/libmbfl/mbfl/mbfilter.c Line 878 in 1d69bf1
PS: Sorry, that's nonsense. Just disregard. |
49ab8a4
to
12cb36d
Compare
12cb36d
to
bfad1ff
Compare
The Windows test failure seems to be related but I can't see how |
I think that test failure is intermittent. |
Can you please also add some tests for empty string + out of bounds offset? Not necessarily for everything, but at least one forward and reverse case. |
bfad1ff
to
d860e06
Compare
MBstring analogous implementation to 6d57848
…when needle length is 0
a037557
to
290e9f1
Compare
if (offset < 0) { | ||
result = haystack_length + offset; | ||
} else { |
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.
Should I move the if (offset < 0)
condition out? As it's the same for both now.
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.
Sounds reasonable.
Azure pipeline failure is unrelated (sapi/fpm/tests/reload-uses-sigkill-as-last-measure.phpt) |
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.
Whew, that was more tricky than I expected :)
if (offset < 0) { | ||
result = haystack_length + offset; | ||
} else { |
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.
Sounds reasonable.
Sorry if this is a newbie question! Is there a bug or an RFC that can be referenced to say why this change was made? |
It was made to be consistent with the non-mbstring version of the function |
These pass on my machine without any test fixes ... So I don't know what to think about this.