Allow '=' character in URL encoded paths and fragments
This commit is contained in:
parent
dca157228e
commit
dd8953faec
3 changed files with 5 additions and 5 deletions
|
@ -91,14 +91,14 @@ namespace Encodings{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// urlencodes std::string data, leaving only the characters A-Za-z0-9~!&()' alone.
|
/// urlencodes std::string data, leaving only the characters A-Za-z0-9~!&()' alone.
|
||||||
std::string URL::encode(const std::string &c){
|
std::string URL::encode(const std::string &c, const std::string &ign){
|
||||||
std::string escaped = "";
|
std::string escaped = "";
|
||||||
int max = c.length();
|
int max = c.length();
|
||||||
for (int i = 0; i < max; i++){
|
for (int i = 0; i < max; i++){
|
||||||
if (('0' <= c[i] && c[i] <= '9') || ('a' <= c[i] && c[i] <= 'z') ||
|
if (('0' <= c[i] && c[i] <= '9') || ('a' <= c[i] && c[i] <= 'z') ||
|
||||||
('A' <= c[i] && c[i] <= 'Z') ||
|
('A' <= c[i] && c[i] <= 'Z') ||
|
||||||
(c[i] == '$' || c[i] == '-' || c[i] == '_' || c[i] == '.' || c[i] == ',' || c[i] == '!' ||
|
(c[i] == '$' || c[i] == '-' || c[i] == '_' || c[i] == '.' || c[i] == ',' || c[i] == '!' ||
|
||||||
c[i] == '*' || c[i] == '(' || c[i] == ')' || c[i] == '/' || c[i] == '\'')){
|
c[i] == '*' || c[i] == '(' || c[i] == ')' || c[i] == '/' || c[i] == '\'') || (ign.size() && ign.find(c[i]) != std::string::npos)){
|
||||||
escaped.append(&c[i], 1);
|
escaped.append(&c[i], 1);
|
||||||
}else{
|
}else{
|
||||||
if (c[i] == ' '){
|
if (c[i] == ' '){
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace Encodings {
|
||||||
/// urldecodes std::string data, parsing out both %-encoded characters and +-encoded spaces.
|
/// urldecodes std::string data, parsing out both %-encoded characters and +-encoded spaces.
|
||||||
static std::string decode(const std::string & in);
|
static std::string decode(const std::string & in);
|
||||||
/// urlencodes std::string data, leaving only the characters A-Za-z0-9~!&()' alone.
|
/// urlencodes std::string data, leaving only the characters A-Za-z0-9~!&()' alone.
|
||||||
static std::string encode(const std::string & c);
|
static std::string encode(const std::string & c, const std::string &ign = "");
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -176,9 +176,9 @@ std::string HTTP::URL::getUrl() const{
|
||||||
}
|
}
|
||||||
if (port.size() && getPort() != getDefaultPort()){ret += ":" + port;}
|
if (port.size() && getPort() != getDefaultPort()){ret += ":" + port;}
|
||||||
ret += "/";
|
ret += "/";
|
||||||
if (path.size()){ret += Encodings::URL::encode(path);}
|
if (path.size()){ret += Encodings::URL::encode(path, "=");}
|
||||||
if (args.size()){ret += "?" + args;}
|
if (args.size()){ret += "?" + args;}
|
||||||
if (frag.size()){ret += "#" + Encodings::URL::encode(frag);}
|
if (frag.size()){ret += "#" + Encodings::URL::encode(frag, "=");}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue