AK: Remove some now-unnecessary workarounds for simdutf base64 usage
Some checks failed
CI / Lagom (arm64, Sanitizer_CI, false, macOS, macos-15, Clang) (push) Has been cancelled
CI / Lagom (x86_64, Fuzzers_CI, false, Linux, blacksmith-16vcpu-ubuntu-2404, Clang) (push) Has been cancelled
CI / Lagom (x86_64, Sanitizer_CI, false, Linux, blacksmith-16vcpu-ubuntu-2404, GNU) (push) Has been cancelled
CI / Lagom (x86_64, Sanitizer_CI, true, Linux, blacksmith-16vcpu-ubuntu-2404, Clang) (push) Has been cancelled
Build Dev Container Image / build (push) Has been cancelled
Package the js repl as a binary artifact / build-and-package (arm64, macOS, macOS-arm64, macos-15) (push) Has been cancelled
Package the js repl as a binary artifact / build-and-package (x86_64, Linux, Linux-x86_64, blacksmith-8vcpu-ubuntu-2404) (push) Has been cancelled
Run test262 and test-wasm / run_and_update_results (push) Has been cancelled
Lint Code / lint (push) Has been cancelled
Label PRs with merge conflicts / auto-labeler (push) Has been cancelled
Push notes / build (push) Has been cancelled
Close stale PRs / stale (push) Has been cancelled
Nightly Windows / CI (push) Has been cancelled

This commit is contained in:
Timothy Flynn 2025-06-01 06:58:47 -04:00 committed by Tim Flynn
parent 3693fd5caa
commit 5e40db5a17
3 changed files with 4 additions and 9 deletions

View File

@ -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)

View File

@ -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" });

View File

@ -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" });