diff options
| author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2024-02-09 23:06:55 +0200 | 
|---|---|---|
| committer | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2024-02-10 00:27:28 +0200 | 
| commit | b8952923ac2564f85b83da6893f89a6a45c952fd (patch) | |
| tree | c790f920ab9c89b60576a6abb19a094adc54061f /indra/llcommon | |
| parent | c8ee05a2712e56a7cdcb2b9e25c8b092c088d4d4 (diff) | |
Triage Issue #49 Better inspection of data urls in media
Diffstat (limited to 'indra/llcommon')
| -rw-r--r-- | indra/llcommon/llbase64.cpp | 16 | ||||
| -rw-r--r-- | indra/llcommon/llbase64.h | 1 | 
2 files changed, 17 insertions, 0 deletions
| diff --git a/indra/llcommon/llbase64.cpp b/indra/llcommon/llbase64.cpp index bb85fe32a3..6591e9b49a 100644 --- a/indra/llcommon/llbase64.cpp +++ b/indra/llcommon/llbase64.cpp @@ -59,3 +59,19 @@ std::string LLBase64::encode(const U8* input, size_t input_size)  	return output;  } +std::string LLBase64::decodeAsString(const std::string &input) +{ +    int b64_buffer_length = apr_base64_decode_len(input.c_str()); +    char* b64_buffer = new char[b64_buffer_length]; + +        // This is faster than apr_base64_encode() if you know +        // you're not on an EBCDIC machine.  Also, the output is +        // null terminated, even though the documentation doesn't +        // specify.  See apr_base64.c for details. JC +    b64_buffer_length = apr_base64_decode(b64_buffer, input.c_str()); +    std::string res; +    res.assign(b64_buffer); +    delete[] b64_buffer; +    return res; +} + diff --git a/indra/llcommon/llbase64.h b/indra/llcommon/llbase64.h index 16d2c217d0..b985963fc4 100644 --- a/indra/llcommon/llbase64.h +++ b/indra/llcommon/llbase64.h @@ -32,6 +32,7 @@ class LL_COMMON_API LLBase64  {  public:  	static std::string encode(const U8* input, size_t input_size); +    static std::string decodeAsString(const std::string& input);  };  #endif | 
