mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
URLdecode the base64 part of the key
This commit is contained in:
parent
b22423e2d5
commit
1bbaa5ba22
@ -5,6 +5,7 @@
|
||||
#include <string>
|
||||
#include <atomic>
|
||||
#include "HTTPProxy.h"
|
||||
#include "util.h"
|
||||
#include "Identity.h"
|
||||
#include "Streaming.h"
|
||||
#include "Destination.h"
|
||||
@ -148,6 +149,7 @@ namespace proxy
|
||||
addressHelperPos = addressHelperPos2;
|
||||
}
|
||||
auto base64 = m_path.substr (addressHelperPos + strlen(helpermark1));
|
||||
base64 = i2p::util::http::urlDecode(base64); //Some of the symbols may be urlencoded
|
||||
LogPrint (eLogDebug,"Jump service for ", m_address, " found at ", base64, ". Inserting to address book");
|
||||
//TODO: this is very dangerous and broken. We should ask the user before doing anything see http://pastethis.i2p/raw/pn5fL4YNJL7OSWj3Sc6N/
|
||||
//TODO: we could redirect the user again to avoid dirtiness in the browser
|
||||
|
11
util.cpp
11
util.cpp
@ -1,3 +1,4 @@
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
@ -444,6 +445,16 @@ namespace http
|
||||
query_.assign(query_i, url_s.end());
|
||||
}
|
||||
|
||||
std::string urlDecode(const std::string& data)
|
||||
{
|
||||
std::string res(data);
|
||||
for (size_t pos = res.find('%'); pos != std::string::npos; pos = res.find('%',pos+1))
|
||||
{
|
||||
char c = strtol(res.substr(pos+1,2).c_str(), NULL, 16);
|
||||
res.replace(pos,3,1,c);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
namespace net
|
||||
|
1
util.h
1
util.h
@ -49,6 +49,7 @@ namespace util
|
||||
std::string httpRequest(const std::string& address);
|
||||
void MergeChunkedResponse (std::istream& response, std::ostream& merged);
|
||||
int httpRequestViaI2pProxy(const std::string& address, std::string &content); // return http code
|
||||
std::string urlDecode(const std::string& data);
|
||||
|
||||
struct url {
|
||||
url(const std::string& url_s); // omitted copy, ==, accessors, ...
|
||||
|
Loading…
Reference in New Issue
Block a user