diff options
author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2014-07-28 15:49:54 -0700 |
---|---|---|
committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2014-07-28 15:49:54 -0700 |
commit | 92aa5cc890bac2730e844ef0c42a5b3ffc7742b9 (patch) | |
tree | a32f887133d1defa4446cd7f00fcbe04ed81d187 /src | |
parent | e0927c28e81b0667dc2c9b949bc6779e04483725 (diff) | |
parent | c9c22eb9f80cb1595953b334f8ef37c6efd484e6 (diff) |
Merge branch 'master' of ssh+git://git.grumpycoder.net/pub/repo.git/Balau
Diffstat (limited to 'src')
-rw-r--r-- | src/BString.cc | 7 | ||||
-rw-r--r-- | src/Http.cc | 22 |
2 files changed, 11 insertions, 18 deletions
diff --git a/src/BString.cc b/src/BString.cc index 5f4b868..f5bcfee 100644 --- a/src/BString.cc +++ b/src/BString.cc @@ -164,13 +164,12 @@ std::vector<Balau::String> Balau::String::tokenize(const String & delimiters, bo pos = strlen(); if ((pos != lastPos) || !trimEmpty) - tokens.push_back(extract(lastPos, pos)); + tokens.push_back(extract(lastPos, pos - lastPos)); return tokens; - } - else { + } else { if ((pos != lastPos) || !trimEmpty) - tokens.push_back(extract(lastPos, pos)); + tokens.push_back(extract(lastPos, pos - lastPos)); } lastPos = pos + 1; 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; } |