diff options
author | Max Kellermann <max@musicpd.org> | 2019-10-15 13:39:02 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2019-10-15 13:39:02 +0200 |
commit | 364acc8949115597752889e8c556cf2162533361 (patch) | |
tree | c32614ccafbeb2478ea99b4b38fb48e636179b0a /src/lib/curl | |
parent | a8f4d2b6fc3f7a616ee8f4e0a920a9cc6475f3bd (diff) |
lib/curl/Escape: add CurlUnescape()
Diffstat (limited to 'src/lib/curl')
-rw-r--r-- | src/lib/curl/Escape.cxx | 16 | ||||
-rw-r--r-- | src/lib/curl/Escape.hxx | 6 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/lib/curl/Escape.cxx b/src/lib/curl/Escape.cxx index 765de3b94..ab832eac9 100644 --- a/src/lib/curl/Escape.cxx +++ b/src/lib/curl/Escape.cxx @@ -53,3 +53,19 @@ CurlEscapeUriPath(StringView src) noexcept CurlEasy easy; return CurlEscapeUriPath(easy.Get(), src); } + +std::string +CurlUnescape(CURL *curl, StringView src) noexcept +{ + int outlength; + CurlString tmp(curl_easy_unescape(curl, src.data, src.size, + &outlength)); + return std::string(tmp.c_str(), outlength); +} + +std::string +CurlUnescape(StringView src) noexcept +{ + CurlEasy easy; + return CurlUnescape(easy.Get(), src); +} diff --git a/src/lib/curl/Escape.hxx b/src/lib/curl/Escape.hxx index e09ed8fed..1a7c9ab70 100644 --- a/src/lib/curl/Escape.hxx +++ b/src/lib/curl/Escape.hxx @@ -42,4 +42,10 @@ CurlEscapeUriPath(CURL *curl, StringView src) noexcept; std::string CurlEscapeUriPath(StringView src) noexcept; +std::string +CurlUnescape(CURL *curl, StringView src) noexcept; + +std::string +CurlUnescape(StringView src) noexcept; + #endif |