[webkit-changes] [WebKit/WebKit] 1d7c9c: [WTF] allow `Base64EncodeMode::URL` to include pad...
Devin Rousso
noreply at github.com
Wed Jul 3 17:00:53 PDT 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 1d7c9c3993271d02efb514b5f3099ce60e6b85f9
https://github.com/WebKit/WebKit/commit/1d7c9c3993271d02efb514b5f3099ce60e6b85f9
Author: Devin Rousso <hi at devinrousso.com>
Date: 2024-07-03 (Wed, 03 Jul 2024)
Changed paths:
M Source/WTF/wtf/text/Base64.cpp
M Source/WTF/wtf/text/Base64.h
M Tools/TestWebKitAPI/Tests/WTF/Base64.cpp
Log Message:
-----------
[WTF] allow `Base64EncodeMode::URL` to include padding
https://bugs.webkit.org/show_bug.cgi?id=275141
Reviewed by Yusuke Suzuki.
Technically "base64url" is the exact same as "base64" but the alphabet slightly adjusted (e.g. `_` instead of `/`), and "base64" by default includes padding, so "base64url" should too.
This will assist with implementing `Uint8Array.prototype.toBase64` since that expects padding to be included regardless of the alphabet <https://webkit.org/b/274635>.
* Source/WTF/wtf/text/Base64.h:
(WTF::base64Encode):
(WTF::base64EncodeToVector):
(WTF::base64EncodeToString):
(WTF::base64EncodeToStringReturnNullIfOverflow):
(WTF::base64URLEncodeToVector):
(WTF::base64URLEncodeToString):
(WTF::base64Encoded):
(WTF::calculateBase64EncodedSize):
(WTF::base64URLEncoded):
(WTF::StringTypeAdapter<Base64Specification>::writeTo const):
* Source/WTF/wtf/text/Base64.cpp:
(WTF::base64EncodeInternal):
(WTF::base64Encode):
(WTF::base64EncodeToVector):
(WTF::base64EncodeToString):
(WTF::base64EncodeToStringReturnNullIfOverflow):
Introduce a `Base64EncodeOption` that's wrapped in an `OptionSet` (for future extensibility) as a parameter for adjusting base64 encoding.
Convert `Base64EncodeMode::URL` into `Base64EncodeOption::URL`.
Add a new `Base64EncodeOption::OmitPadding` that controls whether padding is included instead of assuming it should be omitted if `Base64EncodeOption::URL`.
* Tools/TestWebKitAPI/Tests/WTF/Base64.cpp: Added.
(TestWebKitAPI::TEST(Base64, Encode)):
(TestWebKitAPI::TEST(Base64, EncodeOmitPadding)):
(TestWebKitAPI::TEST(Base64, EncodeURL)):
(TestWebKitAPI::TEST(Base64, EncodeURLOmitPadding)):
* Tools/TestWebKitAPI/CMakeLists.txt:
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
Canonical link: https://commits.webkit.org/280647@main
To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications
More information about the webkit-changes
mailing list