1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:38:11 +00:00

cut: Treat a range containing consecutive commas or dashes as invalid

This commit is contained in:
Tim Ledbetter 2023-06-24 20:34:14 +01:00 committed by Andreas Kling
parent bc56d71252
commit da67d593d8

View file

@ -35,7 +35,7 @@ struct Range {
static bool expand_list(DeprecatedString& list, Vector<Range>& ranges) static bool expand_list(DeprecatedString& list, Vector<Range>& ranges)
{ {
Vector<DeprecatedString> tokens = list.split(','); Vector<DeprecatedString> tokens = list.split(',', SplitBehavior::KeepEmpty);
for (auto& token : tokens) { for (auto& token : tokens) {
if (token.length() == 0) { if (token.length() == 0) {
@ -75,7 +75,7 @@ static bool expand_list(DeprecatedString& list, Vector<Range>& ranges)
ranges.append({ index.value(), SIZE_MAX }); ranges.append({ index.value(), SIZE_MAX });
} else { } else {
auto range = token.split('-'); auto range = token.split('-', SplitBehavior::KeepEmpty);
if (range.size() == 2) { if (range.size() == 2) {
auto index1 = range[0].to_uint(); auto index1 = range[0].to_uint();
if (!index1.has_value()) { if (!index1.has_value()) {