summaryrefslogtreecommitdiffstats
path: root/src/WebAdmin.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-08-09 22:34:59 +0200
committermadmaxoft <github@xoft.cz>2014-08-09 22:34:59 +0200
commit2ab8e763927070eef76963d42933a0d9b87191c2 (patch)
treea958f6f7acdcd808fa75ca1fafe7f9491509fb8d /src/WebAdmin.cpp
parentRankMgr: Added GetRankVisuals() function. (diff)
downloadcuberite-2ab8e763927070eef76963d42933a0d9b87191c2.tar
cuberite-2ab8e763927070eef76963d42933a0d9b87191c2.tar.gz
cuberite-2ab8e763927070eef76963d42933a0d9b87191c2.tar.bz2
cuberite-2ab8e763927070eef76963d42933a0d9b87191c2.tar.lz
cuberite-2ab8e763927070eef76963d42933a0d9b87191c2.tar.xz
cuberite-2ab8e763927070eef76963d42933a0d9b87191c2.tar.zst
cuberite-2ab8e763927070eef76963d42933a0d9b87191c2.zip
Diffstat (limited to 'src/WebAdmin.cpp')
-rw-r--r--src/WebAdmin.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/WebAdmin.cpp b/src/WebAdmin.cpp
index f5dc6fde7..ab6925e55 100644
--- a/src/WebAdmin.cpp
+++ b/src/WebAdmin.cpp
@@ -444,6 +444,38 @@ 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;
+}
+
+
+
+
+
AString cWebAdmin::GetBaseURL(const AStringVector & a_URLSplit)
{
AString BaseURL = "./";