From 16543a704384a7da0b45fd8053434cca1a0dcfd9 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Wed, 25 Jun 2014 15:02:03 -0700 Subject: Fixing tokenize. --- src/BString.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') 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::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; -- cgit v1.2.3 From c9c22eb9f80cb1595953b334f8ef37c6efd484e6 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Fri, 27 Jun 2014 23:12:43 +0200 Subject: Fixing PercentDecode. --- src/Http.cc | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3