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),
|
to_simdutf_last_chunk_handling(last_chunk_handling),
|
||||||
decode_up_to_bad_character);
|
decode_up_to_bad_character);
|
||||||
|
|
||||||
if (result.error == simdutf::BASE64_INPUT_REMAINDER && last_chunk_handling == LastChunkHandling::StopBeforePartial) {
|
if (result.error != simdutf::SUCCESS && result.error != simdutf::OUTPUT_BUFFER_TOO_SMALL) {
|
||||||
result.error = simdutf::SUCCESS;
|
|
||||||
} else if (result.error != simdutf::SUCCESS && result.error != simdutf::OUTPUT_BUFFER_TOO_SMALL) {
|
|
||||||
output.resize((result.count / 4) * 3);
|
output.resize((result.count / 4) * 3);
|
||||||
|
|
||||||
auto error = [&]() {
|
auto error = [&]() {
|
||||||
|
@ -69,10 +67,7 @@ static ErrorOr<size_t, InvalidBase64> decode_base64_into_impl(StringView input,
|
||||||
VERIFY(output_length <= output.size());
|
VERIFY(output_length <= output.size());
|
||||||
output.resize(output_length);
|
output.resize(output_length);
|
||||||
|
|
||||||
if (last_chunk_handling == LastChunkHandling::StopBeforePartial)
|
return result.count;
|
||||||
return input.length() - (input.length() % 4);
|
|
||||||
|
|
||||||
return result.error == simdutf::SUCCESS ? input.length() : result.count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ErrorOr<ByteBuffer> decode_base64_impl(StringView input, LastChunkHandling last_chunk_handling, simdutf::base64_options options)
|
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", () => {
|
test("invalid padding", () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
Uint8Array.fromBase64("Zm9v=", { lastChunkHandling: "strict" });
|
Uint8Array.fromBase64("Zm9v=", { lastChunkHandling: "strict" });
|
||||||
}).toThrowWithMessage(SyntaxError, "Invalid trailing data");
|
}).toThrowWithMessage(SyntaxError, "Invalid base64 character");
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
Uint8Array.fromBase64("Zm9vaa=", { lastChunkHandling: "strict" });
|
Uint8Array.fromBase64("Zm9vaa=", { lastChunkHandling: "strict" });
|
||||||
|
|
|
@ -79,7 +79,7 @@ describe("errors", () => {
|
||||||
test("invalid padding", () => {
|
test("invalid padding", () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
new Uint8Array(10).setFromBase64("Zm9v=", { lastChunkHandling: "strict" });
|
new Uint8Array(10).setFromBase64("Zm9v=", { lastChunkHandling: "strict" });
|
||||||
}).toThrowWithMessage(SyntaxError, "Invalid trailing data");
|
}).toThrowWithMessage(SyntaxError, "Invalid base64 character");
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
new Uint8Array(10).setFromBase64("Zm9vaa=", { lastChunkHandling: "strict" });
|
new Uint8Array(10).setFromBase64("Zm9vaa=", { lastChunkHandling: "strict" });
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue