standard: Validate sort_type argument in array_unique()#21110
standard: Validate sort_type argument in array_unique()#21110arshidkv12 wants to merge 11 commits intophp:masterfrom
Conversation
iluuu1994
left a comment
There was a problem hiding this comment.
It looks like this is also missing handling for SORT_FLAG_CASE, which looks to be untested. https://3v4l.org/dqSln This is just from a very quick look, there might be other issues.
iluuu1994
left a comment
There was a problem hiding this comment.
Marking as "Request changes" for visibility.
Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
I don’t see |
…into array_unique
|
It's not documented, but it's there, as demonstrated by the 3v4l. |
iluuu1994
left a comment
There was a problem hiding this comment.
That's all the issues I could find. Please somebody else verify. I'm not code owner.
| if (base_sort != PHP_SORT_REGULAR | ||
| && base_sort != PHP_SORT_NUMERIC | ||
| && base_sort != PHP_SORT_STRING | ||
| && base_sort != PHP_SORT_LOCALE_STRING) { |
There was a problem hiding this comment.
There's also SORT_NATURAL. I don't know whether it would differ in behavior from SORT_STRING, but even if it doesn't it should continue to be accepted.
There was a problem hiding this comment.
It works with sort_type & ~PHP_SORT_FLAG_CASE only in php_get_data_compare_func_unstable.
Ref:
https://github.com/php/php-src/blob/master/ext/standard/array.c#L495-L556
Girgias
left a comment
There was a problem hiding this comment.
I wonder if it doesn't make more sense to handle this error in php_get_data_compare_func_unstable() (and possibly the related functions)` to also deal with invalid flags for all the sort functions.
|
@Girgias Ref: |
|
@arshidkv12 |
The
array_unique()now validates thesort_typeargument and throwsValueErrorwhen an unsupported value is provided.