From 3e200f539fd6523a26a89dd21b1c966f3e8b1486 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Mon, 9 Jan 2023 14:32:57 -0800 Subject: Clarify that Base64 unescaping methods expect their inputs to match particular RFC specifications. PiperOrigin-RevId: 500809781 Change-Id: I34d089343321f7658db8252ad29ff1824e6dbef2 --- absl/strings/escaping.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/absl/strings/escaping.h b/absl/strings/escaping.h index d2c18e02..f47cf736 100644 --- a/absl/strings/escaping.h +++ b/absl/strings/escaping.h @@ -135,20 +135,21 @@ std::string WebSafeBase64Escape(absl::string_view src); // Base64Unescape() // -// Converts a `src` string encoded in Base64 to its binary equivalent, writing -// it to a `dest` buffer, returning `true` on success. If `src` contains invalid -// characters, `dest` is cleared and returns `false`. -// Padding is optional. If padding is included, it must be correct. In the -// padding, '=' and '.' are treated identically. +// Converts a `src` string encoded in Base64 (RFC 4648 section 4) to its binary +// equivalent, writing it to a `dest` buffer, returning `true` on success. If +// `src` contains invalid characters, `dest` is cleared and returns `false`. +// Padding is optional, and note that `Base64Escape()` does not produce it. If +// padding is included, it must be correct. In the padding, '=' and '.' are +// treated identically. bool Base64Unescape(absl::string_view src, std::string* dest); // WebSafeBase64Unescape() // -// Converts a `src` string encoded in Base64 to its binary equivalent, writing -// it to a `dest` buffer, but using '-' instead of '+', and '_' instead of '/'. -// If `src` contains invalid characters, `dest` is cleared and returns `false`. -// Padding is optional. If padding is included, it must be correct. In the -// padding, '=' and '.' are treated identically. +// Converts a `src` string encoded in "web safe" Base64 (RFC 4648 section 5) to +// its binary equivalent, writing it to a `dest` buffer. If `src` contains +// invalid characters, `dest` is cleared and returns `false`. If padding is +// included, it must be correct. In the padding, '=' and '.' are treated +// identically. bool WebSafeBase64Unescape(absl::string_view src, std::string* dest); // HexStringToBytes() -- cgit v1.2.3