40 std::string warning_message;
43 char hexToChar(
char first,
char second )
const;
49 URL(
const std::string& s ){ url = s; };
58 std::string
warning()
const {
return warning_message; };
63inline char URL::hexToChar (
char first,
char second )
const {
65 digit = (first >=
'A' ? ((first & 0xDF) -
'A') + 10 : (first -
'0'));
67 digit += (second >=
'A' ? ((second & 0xDF) -
'A') + 10 : (second -
'0'));
68 return static_cast<char>(digit);
77 std::string::iterator iter;
80 for(iter = url.begin(); iter != url.end(); ++iter) {
83 argument.append(1,
' ');
87 if( std::distance(iter, url.end()) >= 2 &&
88 std::isxdigit(*(iter + 1)) && std::isxdigit(*(iter + 2)) ){
91 if( (*(iter+1)==
'0' && *(iter+2)==
'0') ){
92 warning_message =
"Warning! Detected embedded NULL byte in URL: " + url;
99 argument.append(1,hexToChar(c,*++iter));
104 argument.append(1,
'%');
109 argument.append(1,*iter);
122 std::string input = this->
decode();
124 for(
unsigned int i=0; i<input.length(); i++ ){
Simple utility class to decode and filter URLs.
Definition: URL.h:32
std::string escape()
String escaping for JSON etc.
Definition: URL.h:119
std::string decode()
Decode and filter URL.
Definition: URL.h:74
std::string warning() const
Return any warning message.
Definition: URL.h:58
URL(const std::string &s)
Constructor.
Definition: URL.h:49