mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-07 21:17:07 +09:00
AK: Remove some now-unnecessary workarounds for simdutf base64 usage
This commit is contained in:
parent
3693fd5caa
commit
5e40db5a17
Notes:
github-actions[bot]
2025-06-01 12:04:06 +00:00
Author: https://github.com/trflynn89
Commit: 5e40db5a17
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4948
3 changed files with 4 additions and 9 deletions
|
@ -45,9 +45,7 @@ static ErrorOr<size_t, InvalidBase64> decode_base64_into_impl(StringView input,
|
|||
to_simdutf_last_chunk_handling(last_chunk_handling),
|
||||
decode_up_to_bad_character);
|
||||
|
||||
if (result.error == simdutf::BASE64_INPUT_REMAINDER && last_chunk_handling == LastChunkHandling::StopBeforePartial) {
|
||||
result.error = simdutf::SUCCESS;
|
||||
} else if (result.error != simdutf::SUCCESS && result.error != simdutf::OUTPUT_BUFFER_TOO_SMALL) {
|
||||
if (result.error != simdutf::SUCCESS && result.error != simdutf::OUTPUT_BUFFER_TOO_SMALL) {
|
||||
output.resize((result.count / 4) * 3);
|
||||
|
||||
auto error = [&]() {
|
||||
|
@ -69,10 +67,7 @@ static ErrorOr<size_t, InvalidBase64> decode_base64_into_impl(StringView input,
|
|||
VERIFY(output_length <= output.size());
|
||||
output.resize(output_length);
|
||||
|
||||
if (last_chunk_handling == LastChunkHandling::StopBeforePartial)
|
||||
return input.length() - (input.length() % 4);
|
||||
|
||||
return result.error == simdutf::SUCCESS ? input.length() : result.count;
|
||||
return result.count;
|
||||
}
|
||||
|
||||
static ErrorOr<ByteBuffer> decode_base64_impl(StringView input, LastChunkHandling last_chunk_handling, simdutf::base64_options options)
|
||||
|
|
|
@ -40,7 +40,7 @@ describe("errors", () => {
|
|||
test("invalid padding", () => {
|
||||
expect(() => {
|
||||
Uint8Array.fromBase64("Zm9v=", { lastChunkHandling: "strict" });
|
||||
}).toThrowWithMessage(SyntaxError, "Invalid trailing data");
|
||||
}).toThrowWithMessage(SyntaxError, "Invalid base64 character");
|
||||
|
||||
expect(() => {
|
||||
Uint8Array.fromBase64("Zm9vaa=", { lastChunkHandling: "strict" });
|
||||
|
|
|
@ -79,7 +79,7 @@ describe("errors", () => {
|
|||
test("invalid padding", () => {
|
||||
expect(() => {
|
||||
new Uint8Array(10).setFromBase64("Zm9v=", { lastChunkHandling: "strict" });
|
||||
}).toThrowWithMessage(SyntaxError, "Invalid trailing data");
|
||||
}).toThrowWithMessage(SyntaxError, "Invalid base64 character");
|
||||
|
||||
expect(() => {
|
||||
new Uint8Array(10).setFromBase64("Zm9vaa=", { lastChunkHandling: "strict" });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue