diff options
-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; } |