Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions base64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@
#include "base64.h"

#include <algorithm>

#if defined(__cpp_exceptions)
#include <stdexcept>
#else
#include <cassert>
#endif

//
// Depending on the url parameter in base64_chars, one of
Expand Down Expand Up @@ -67,7 +72,11 @@ static unsigned int pos_of_char(const unsigned char chr) {
// 2020-10-23: Throw std::exception rather than const char*
//(Pablo Martin-Gomez, https://github.com/Bouska)
//
#if defined(__cpp_exceptions)
throw std::runtime_error("Input is not valid base64-encoded data.");
#else
assert(!"Input is not valid base64-encoded data.");
#endif
}

static std::string insert_linebreaks(std::string str, size_t distance) {
Expand Down Expand Up @@ -280,3 +289,4 @@ std::string base64_decode(std::string_view s, bool remove_linebreaks) {
}

#endif // __cplusplus >= 201703L