mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-03 08:08:43 +00:00
AK+LibJS: Use simdutf for all base64 operations
We were previously unable to use simdutf for base64 decoding operations other than "loose". Upstream has added support for the "strict" and "stop-before-partial" operations, so let's make use of them!
This commit is contained in:
parent
e04545979f
commit
8a80ff7b3b
Notes:
github-actions[bot]
2025-05-03 15:22:03 +00:00
Author: https://github.com/trflynn89
Commit: 8a80ff7b3b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4568
6 changed files with 88 additions and 370 deletions
|
@ -40,25 +40,25 @@ describe("errors", () => {
|
|||
test("invalid padding", () => {
|
||||
expect(() => {
|
||||
Uint8Array.fromBase64("Zm9v=", { lastChunkHandling: "strict" });
|
||||
}).toThrowWithMessage(SyntaxError, "Unexpected padding character");
|
||||
}).toThrowWithMessage(SyntaxError, "Invalid trailing data");
|
||||
|
||||
expect(() => {
|
||||
Uint8Array.fromBase64("Zm9vaa=", { lastChunkHandling: "strict" });
|
||||
}).toThrowWithMessage(SyntaxError, "Incomplete number of padding characters");
|
||||
}).toThrowWithMessage(SyntaxError, "Invalid trailing data");
|
||||
|
||||
expect(() => {
|
||||
Uint8Array.fromBase64("Zm9vaa=a", { lastChunkHandling: "strict" });
|
||||
}).toThrowWithMessage(SyntaxError, "Unexpected padding character");
|
||||
}).toThrowWithMessage(SyntaxError, "Invalid base64 character");
|
||||
});
|
||||
|
||||
test("invalid alphabet", () => {
|
||||
expect(() => {
|
||||
Uint8Array.fromBase64("-", { lastChunkHandling: "strict" });
|
||||
}).toThrowWithMessage(SyntaxError, "Invalid character '-'");
|
||||
}).toThrowWithMessage(SyntaxError, "Invalid base64 character");
|
||||
|
||||
expect(() => {
|
||||
Uint8Array.fromBase64("+", { alphabet: "base64url", lastChunkHandling: "strict" });
|
||||
}).toThrowWithMessage(SyntaxError, "Invalid character '+'");
|
||||
}).toThrowWithMessage(SyntaxError, "Invalid base64 character");
|
||||
});
|
||||
|
||||
test("overlong chunk", () => {
|
||||
|
|
|
@ -79,28 +79,28 @@ describe("errors", () => {
|
|||
test("invalid padding", () => {
|
||||
expect(() => {
|
||||
new Uint8Array(10).setFromBase64("Zm9v=", { lastChunkHandling: "strict" });
|
||||
}).toThrowWithMessage(SyntaxError, "Unexpected padding character");
|
||||
}).toThrowWithMessage(SyntaxError, "Invalid trailing data");
|
||||
|
||||
expect(() => {
|
||||
new Uint8Array(10).setFromBase64("Zm9vaa=", { lastChunkHandling: "strict" });
|
||||
}).toThrowWithMessage(SyntaxError, "Incomplete number of padding characters");
|
||||
}).toThrowWithMessage(SyntaxError, "Invalid trailing data");
|
||||
|
||||
expect(() => {
|
||||
new Uint8Array(10).setFromBase64("Zm9vaa=a", { lastChunkHandling: "strict" });
|
||||
}).toThrowWithMessage(SyntaxError, "Unexpected padding character");
|
||||
}).toThrowWithMessage(SyntaxError, "Invalid base64 character");
|
||||
});
|
||||
|
||||
test("invalid alphabet", () => {
|
||||
expect(() => {
|
||||
new Uint8Array(10).setFromBase64("-", { lastChunkHandling: "strict" });
|
||||
}).toThrowWithMessage(SyntaxError, "Invalid character '-'");
|
||||
}).toThrowWithMessage(SyntaxError, "Invalid base64 character");
|
||||
|
||||
expect(() => {
|
||||
new Uint8Array(10).setFromBase64("+", {
|
||||
alphabet: "base64url",
|
||||
lastChunkHandling: "strict",
|
||||
});
|
||||
}).toThrowWithMessage(SyntaxError, "Invalid character '+'");
|
||||
}).toThrowWithMessage(SyntaxError, "Invalid base64 character");
|
||||
});
|
||||
|
||||
test("overlong chunk", () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue