/* Copyright (C) 2000-2001 Dawit Alemayehu <[email protected]> Copyright (C) 2006 Alexey Proskuryakov <[email protected]> Copyright (C) 2007, 2008 Apple Inc. All rights reserved. Copyright (C) 2010 Patrick Gansterer <[email protected]> This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Library General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. This code is based on the java implementation in HTTPClient package by Ronald Tschalaer Copyright (C) 1996-1999. */ #ifdef UNSAFE_BUFFERS_BUILD // TODO(crbug.com/351564777): Remove this and convert code to safer constructs. #pragma allow_unsafe_buffers #endif #include "third_party/blink/renderer/platform/wtf/text/base64.h" #include <limits.h> #include "third_party/blink/renderer/platform/wtf/text/string_buffer.h" #include "third_party/blink/renderer/platform/wtf/text/string_utf8_adaptor.h" #include "third_party/modp_b64/modp_b64.h" namespace WTF { namespace { // https://infra.spec.whatwg.org/#ascii-whitespace // Matches the definition of IsHTMLSpace in html_parser_idioms.h. template <typename CharType> bool IsAsciiWhitespace(CharType character) { … } ModpDecodePolicy GetModpPolicy(Base64DecodePolicy policy) { … } // Invokes modp_b64 without stripping whitespace. bool Base64DecodeRaw(const StringView& in, Vector<char>& out, Base64DecodePolicy policy) { … } } // namespace String Base64Encode(base::span<const uint8_t> data) { … } void Base64Encode(base::span<const uint8_t> data, Vector<char>& out) { … } bool Base64Decode(const StringView& in, Vector<char>& out, Base64DecodePolicy policy) { … } bool Base64UnpaddedURLDecode(const String& in, Vector<char>& out) { … } String Base64URLEncode(const char* data, unsigned length) { … } String NormalizeToBase64(const String& encoding) { … } } // namespace WTF