-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[WTF] allow Base64EncodeMode::URL
to include padding
#29530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
9e885ca
to
c6a36bb
Compare
EWS run on previous version of this PR (hash 9e885ca) |
EWS run on previous version of this PR (hash cdcee4b) |
EWS run on previous version of this PR (hash c6a36bb) |
1 similar comment
Hmm, part of the premise of this JS API was that it wouldn't require implementations to support more permutations. I guess this is not too bad, but it still seems unfortunate. Any reason not to just make it three modes?
I don't think you ever want the Default without padding. |
Also some test coverage would be good. |
actually, there's currently some discussion around having an i think an options set is probably preferred as it allows for far more flexibility in the future if new things are added |
EWS run on previous version of this PR (hash 2dd13f7) |
EWS run on previous version of this PR (hash c7922b9) |
EWS run on previous version of this PR (hash 25a8349) |
EWS run on previous version of this PR (hash 1b70f97) |
EWS run on current version of this PR (hash f082f21) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me
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
f082f21
to
1d7c9c3
Compare
Committed 280647@main (1d7c9c3): https://commits.webkit.org/280647@main Reviewed commits have been landed. Closing PR #29530 and removing active labels. |
1d7c9c3
f082f21