From b3b723b4531a3781ab847a2652cf192303e78941 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 25 Dec 2016 18:29:21 +0100 Subject: Refactored to put URL Encoding / Decoding in a single place. (#3491) --- src/WebAdmin.cpp | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) (limited to 'src/WebAdmin.cpp') diff --git a/src/WebAdmin.cpp b/src/WebAdmin.cpp index 5c08deb0d..1e60b7c0e 100644 --- a/src/WebAdmin.cpp +++ b/src/WebAdmin.cpp @@ -602,30 +602,7 @@ AString cWebAdmin::GetHTMLEscapedString(const AString & a_Input) AString cWebAdmin::GetURLEncodedString(const AString & a_Input) { - // Translation table from nibble to hex: - static const char Hex[] = "0123456789abcdef"; - - // Preallocate the output to match input: - AString dst; - size_t len = a_Input.length(); - dst.reserve(len); - - // Loop over input and substitute whatever is needed: - for (size_t i = 0; i < len; i++) - { - char ch = a_Input[i]; - if (isalnum(ch) || (ch == '-') || (ch == '_') || (ch == '.') || (ch == '~')) - { - dst.push_back(ch); - } - else - { - dst.push_back('%'); - dst.push_back(Hex[(ch >> 4) & 0x0f]); - dst.push_back(Hex[ch & 0x0f]); - } - } // for i - a_Input[] - return dst; + return URLEncode(a_Input); } -- cgit v1.2.3