diff --git a/Userland/Libraries/LibWeb/Infra/Base64.cpp b/Userland/Libraries/LibWeb/Infra/Base64.cpp index 7944b5e427..898006b0de 100644 --- a/Userland/Libraries/LibWeb/Infra/Base64.cpp +++ b/Userland/Libraries/LibWeb/Infra/Base64.cpp @@ -8,9 +8,11 @@ #include #include #include +#include #include #include #include +#include namespace Web::Infra { @@ -18,7 +20,13 @@ namespace Web::Infra { ErrorOr decode_forgiving_base64(StringView input) { // 1. Remove all ASCII whitespace from data. - auto data = input.trim_whitespace(); + // FIXME: It is possible to avoid copying input here, it's just a bit tricky to remove the equal signs + StringBuilder builder; + for (auto character : input) { + if (!is_ascii_whitespace(character)) + TRY(builder.try_append(character)); + } + auto data = builder.string_view(); // 2. If data’s code point length divides by 4 leaving no remainder, then: if (data.length() % 4 == 0) {