summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2014-06-27 23:12:43 +0200
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2014-06-27 23:12:43 +0200
commitc9c22eb9f80cb1595953b334f8ef37c6efd484e6 (patch)
tree288a2a86eb05ca7cb4fc904c1b857836caf55d5b /src
parent16543a704384a7da0b45fd8053434cca1a0dcfd9 (diff)
Fixing PercentDecode.
Diffstat (limited to 'src')
-rw-r--r--src/Http.cc22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/Http.cc b/src/Http.cc
index c645836..c1bdfc1 100644
--- a/src/Http.cc
+++ b/src/Http.cc
@@ -85,8 +85,7 @@ Balau::String Balau::Http::percentEncode(const String & src) {
char c = src[i];
if (((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z')) || (c == '-') || (c == '.') || (c == '_') || (c == '~')) {
ret += c;
- }
- else {
+ } else {
ret += '%';
ret += toHex[c >> 4];
ret += toHex[c & 15];
@@ -105,34 +104,29 @@ Balau::String Balau::Http::percentDecode(const String & src) {
char c = src[i];
if (((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z')) || (c == '-') || (c == '.') || (c == '_') || (c == '~')) {
ret += c;
- }
- else if ((c == '%') && ((i + 2) < size)) {
+ } else if ((c == '%') && ((i + 2) < size)) {
char h1 = src[i + 1];
char h2 = src[i + 2];
if ((h1 >= '0') && (h1 <= '9')) {
c = h1 - '0';
- }
- else if ((h1 >= 'A') && (h1 <= 'F')) {
+ } else if ((h1 >= 'A') && (h1 <= 'F')) {
c = h1 - 'A' + 10;
- }
- else {
+ } else {
// invalid
return ret;
}
c <<= 4;
if ((h2 >= '0') && (h2 <= '9')) {
c |= h2 - '0';
- }
- else if ((h2 >= 'A') && (h2 <= 'F')) {
+ } else if ((h2 >= 'A') && (h2 <= 'F')) {
c |= h2 - 'A' + 10;
- }
- else {
+ } else {
// invalid
return ret;
}
i += 2;
- }
- else {
+ ret += c;
+ } else {
// invalid
return ret;
}