Deprecate the versions of Base64Escape() and WebSafeBase64Escape() that use an output parameter. These versions are clearly inferior to the versions that return a string. This is a response to https://github.com/abseil/abseil-cpp/issues/2015 Fixes #2015 PiperOrigin-RevId: 870281461 Change-Id: I92f23d51d05a243dde88c997c1e8448819c5bc77
diff --git a/absl/strings/escaping.cc b/absl/strings/escaping.cc index 9f887b8..1171e8d 100644 --- a/absl/strings/escaping.cc +++ b/absl/strings/escaping.cc
@@ -954,19 +954,6 @@ return Base64UnescapeInternal(src.data(), src.size(), dest, kUnWebSafeBase64); } -void Base64Escape(absl::string_view src, std::string* absl_nonnull dest) { - strings_internal::Base64EscapeInternal( - reinterpret_cast<const unsigned char*>(src.data()), src.size(), dest, - true, strings_internal::kBase64Chars); -} - -void WebSafeBase64Escape(absl::string_view src, - std::string* absl_nonnull dest) { - strings_internal::Base64EscapeInternal( - reinterpret_cast<const unsigned char*>(src.data()), src.size(), dest, - false, strings_internal::kWebSafeBase64Chars); -} - std::string Base64Escape(absl::string_view src) { std::string dest; strings_internal::Base64EscapeInternal(
diff --git a/absl/strings/escaping.h b/absl/strings/escaping.h index 3aaf39c..aaacc28 100644 --- a/absl/strings/escaping.h +++ b/absl/strings/escaping.h
@@ -126,16 +126,26 @@ // Encodes a `src` string into a base64-encoded 'dest' string with padding // characters. This function conforms with RFC 4648 section 4 (base64) and RFC // 2045. -void Base64Escape(absl::string_view src, std::string* absl_nonnull dest); std::string Base64Escape(absl::string_view src); +[[deprecated( + "Use the string-returning version of " + "Base64Escape()")]] ABSL_REFACTOR_INLINE inline void +Base64Escape(absl::string_view src, std::string* absl_nonnull dest) { + *dest = Base64Escape(src); +} // WebSafeBase64Escape() // // Encodes a `src` string into a base64 string, like Base64Escape() does, but // outputs '-' instead of '+' and '_' instead of '/', and does not pad 'dest'. // This function conforms with RFC 4648 section 5 (base64url). -void WebSafeBase64Escape(absl::string_view src, std::string* absl_nonnull dest); std::string WebSafeBase64Escape(absl::string_view src); +[[deprecated( + "Use the string-returning version of " + "WebSafeBase64Escape()")]] ABSL_REFACTOR_INLINE inline void +WebSafeBase64Escape(absl::string_view src, std::string* absl_nonnull dest) { + *dest = WebSafeBase64Escape(src); +} // Base64Unescape() //