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 <util/url.h> 6 : 7 : #include <event2/http.h> 8 : #include <stdlib.h> 9 : #include <string> 10 : 11 1730 : std::string urlDecode(const std::string &urlEncoded) { 12 1730 : std::string res; 13 1730 : if (!urlEncoded.empty()) { 14 1570 : char *decoded = evhttp_uridecode(urlEncoded.c_str(), false, nullptr); 15 1570 : if (decoded) { 16 1570 : res = std::string(decoded); 17 1570 : free(decoded); 18 : } 19 1570 : } 20 : return res; 21 1730 : }