From 64235edb41c1c85ed32211fc719e6a7d65f5daf0 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Tue, 31 Jan 2006 19:09:43 +0000 Subject: Fixed encoding of reserved/unsafe chars. --- src/utility/urlUtils.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/utility/urlUtils.cpp') diff --git a/src/utility/urlUtils.cpp b/src/utility/urlUtils.cpp index 4fde4916..0a0bfce0 100644 --- a/src/utility/urlUtils.cpp +++ b/src/utility/urlUtils.cpp @@ -27,6 +27,10 @@ namespace utility { const string urlUtils::encode(const string& s) { + static const string RESERVED_CHARS = + /* reserved */ "$&+,/:;=?@" + /* unsafe */ "<>#%{}[]|\\^\"~`"; + string result; result.reserve(s.length()); @@ -35,8 +39,8 @@ const string urlUtils::encode(const string& s) const char_t c = *it; if (parserHelpers::isPrint(c) && !parserHelpers::isSpace(c) && - c != '%' && c != '=' && c != '?' && c != '&' && - c != '@' && c != '/' && c != ':') + static_cast (c) <= 127 && + RESERVED_CHARS.find(c) == string::npos) { result += c; } -- cgit v1.2.3