diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.cpp
index 72d3f1036d..9fc068cd4d 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.cpp
@@ -108,7 +108,7 @@ DeprecatedString HTMLOptionElement::text() const
});
// Return the result of stripping and collapsing ASCII whitespace from the above concatenation.
- return Infra::strip_and_collapse_whitespace(builder.string_view());
+ return Infra::strip_and_collapse_whitespace(builder.string_view()).release_value_but_fixme_should_propagate_errors().to_deprecated_string();
}
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-option-text
diff --git a/Userland/Libraries/LibWeb/Infra/Strings.cpp b/Userland/Libraries/LibWeb/Infra/Strings.cpp
index 09e7c2ad23..793dfb2213 100644
--- a/Userland/Libraries/LibWeb/Infra/Strings.cpp
+++ b/Userland/Libraries/LibWeb/Infra/Strings.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, Linus Groh
+ * Copyright (c) 2022-2023, Linus Groh
* Copyright (c) 2022, networkException
* Copyright (c) 2023, Kenneth Myhra
* Copyright (c) 2023, Sam Atkins
@@ -8,7 +8,7 @@
*/
#include
-#include
+#include
#include
#include
#include
@@ -41,7 +41,7 @@ bool is_ascii_case_insensitive_match(StringView a, StringView b)
}
// https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
-DeprecatedString strip_and_collapse_whitespace(StringView string)
+ErrorOr strip_and_collapse_whitespace(StringView string)
{
// Replace any sequence of one or more consecutive code points that are ASCII whitespace in the string with a single U+0020 SPACE code point.
StringBuilder builder;
@@ -51,11 +51,11 @@ DeprecatedString strip_and_collapse_whitespace(StringView string)
builder.append(' ');
continue;
}
- builder.append_code_point(code_point);
+ TRY(builder.try_append_code_point(code_point));
}
// ...and then remove any leading and trailing ASCII whitespace from that string.
- return builder.string_view().trim(Infra::ASCII_WHITESPACE);
+ return String::from_utf8(builder.string_view().trim(Infra::ASCII_WHITESPACE));
}
// https://infra.spec.whatwg.org/#code-unit-prefix
diff --git a/Userland/Libraries/LibWeb/Infra/Strings.h b/Userland/Libraries/LibWeb/Infra/Strings.h
index 7712f19dfa..b13fb90a3b 100644
--- a/Userland/Libraries/LibWeb/Infra/Strings.h
+++ b/Userland/Libraries/LibWeb/Infra/Strings.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, Linus Groh
+ * Copyright (c) 2022-2023, Linus Groh
* Copyright (c) 2022, networkException
* Copyright (c) 2023, Kenneth Myhra
* Copyright (c) 2023, Sam Atkins
@@ -14,7 +14,7 @@
namespace Web::Infra {
bool is_ascii_case_insensitive_match(StringView a, StringView b);
-DeprecatedString strip_and_collapse_whitespace(StringView string);
+ErrorOr strip_and_collapse_whitespace(StringView string);
bool is_code_unit_prefix(StringView potential_prefix, StringView input);
ErrorOr convert_to_scalar_value_string(StringView string);
ErrorOr to_ascii_lowercase(StringView string);