From da67d593d8b75ff3d201d045d605f6465a08c6be Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Sat, 24 Jun 2023 20:34:14 +0100 Subject: [PATCH] cut: Treat a range containing consecutive commas or dashes as invalid --- Userland/Utilities/cut.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Utilities/cut.cpp b/Userland/Utilities/cut.cpp index 12a2a5079dd..c0e3d252b39 100644 --- a/Userland/Utilities/cut.cpp +++ b/Userland/Utilities/cut.cpp @@ -35,7 +35,7 @@ struct Range { static bool expand_list(DeprecatedString& list, Vector& ranges) { - Vector tokens = list.split(','); + Vector tokens = list.split(',', SplitBehavior::KeepEmpty); for (auto& token : tokens) { if (token.length() == 0) { @@ -75,7 +75,7 @@ static bool expand_list(DeprecatedString& list, Vector& ranges) ranges.append({ index.value(), SIZE_MAX }); } else { - auto range = token.split('-'); + auto range = token.split('-', SplitBehavior::KeepEmpty); if (range.size() == 2) { auto index1 = range[0].to_uint(); if (!index1.has_value()) {