Line data Source code
1 : // Copyright (c) 2015-2019 The Bitcoin Core developers 2 : // Distributed under the MIT software license, see the accompanying 3 : // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 : 5 : #include <common/url.h> 6 : 7 : #include <event2/http.h> 8 : 9 : #include <cstdlib> 10 : #include <string> 11 : 12 15559 : std::string urlDecode(const std::string &urlEncoded) { 13 15559 : std::string res; 14 15559 : if (!urlEncoded.empty()) { 15 14469 : char *decoded = evhttp_uridecode(urlEncoded.c_str(), false, nullptr); 16 14469 : if (decoded) { 17 14469 : res = std::string(decoded); 18 14469 : free(decoded); 19 14469 : } 20 14469 : } 21 15559 : return res; 22 15559 : }