mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
AK: Fix String[View]::split_view() returning an extra empty part
If the last character was the separator and keep_empty is true, the previous if statement would have already appended the last empty part, so no need to do this again. This was even more problematic, because the result of split_view() is expected to consist of true substrings that are usable with the StringView::substring_view_starting_*_substring() methods, not of equal strings located elsewhere. Fixes https://github.com/SerenityOS/serenity/issues/970 See https://github.com/SerenityOS/serenity/pull/938
This commit is contained in:
parent
7ad9bfbc68
commit
499612482b
Notes:
sideshowbarker
2024-07-19 10:04:00 +09:00
Author: https://github.com/bugaevc Commit: https://github.com/SerenityOS/serenity/commit/499612482bc Pull-request: https://github.com/SerenityOS/serenity/pull/1076
2 changed files with 0 additions and 4 deletions
|
@ -153,8 +153,6 @@ Vector<StringView> String::split_view(const char separator, bool keep_empty) con
|
|||
size_t taillen = length() - substart;
|
||||
if (taillen != 0 || keep_empty)
|
||||
v.append(substring_view(substart, taillen));
|
||||
if (characters()[length() - 1] == separator && keep_empty)
|
||||
v.append(empty());
|
||||
return v;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,8 +35,6 @@ Vector<StringView> StringView::split_view(const char separator, bool keep_empty)
|
|||
size_t taillen = length() - substart;
|
||||
if (taillen != 0 || keep_empty)
|
||||
v.append(substring_view(substart, taillen));
|
||||
if (characters_without_null_termination()[length() - 1] == separator && keep_empty)
|
||||
v.append(String::empty());
|
||||
return v;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue