Changeset View
Changeset View
Standalone View
Standalone View
src/util/url.cpp
// Copyright (c) 2015-2018 The Bitcoin Core developers | // Copyright (c) 2015-2018 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <util/url.h> | #include <util/url.h> | ||||
#include <cstdlib> | #include <cstdlib> | ||||
#include <event2/http.h> | #include <event2/http.h> | ||||
#include <string> | |||||
std::string urlDecode(const std::string &urlEncoded) { | std::string urlDecode(const std::string &urlEncoded) { | ||||
std::string res; | std::string res; | ||||
if (!urlEncoded.empty()) { | if (!urlEncoded.empty()) { | ||||
char *decoded = evhttp_uridecode(urlEncoded.c_str(), false, nullptr); | char *decoded = evhttp_uridecode(urlEncoded.c_str(), false, nullptr); | ||||
if (decoded) { | if (decoded) { | ||||
res = std::string(decoded); | res = std::string(decoded); | ||||
free(decoded); | free(decoded); | ||||
} | } | ||||
} | } | ||||
return res; | return res; | ||||
} | } |