WebAdmin: Added GetURLEncodedString().
This commit is contained in:
parent
27a818e173
commit
dcef688ccc
@ -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 cWebAdmin::GetBaseURL(const AStringVector & a_URLSplit)
|
||||||
{
|
{
|
||||||
AString BaseURL = "./";
|
AString BaseURL = "./";
|
||||||
|
@ -135,13 +135,16 @@ public:
|
|||||||
/** Escapes text passed into it, so it can be embedded into html. */
|
/** Escapes text passed into it, so it can be embedded into html. */
|
||||||
static AString GetHTMLEscapedString(const AString & a_Input);
|
static AString GetHTMLEscapedString(const AString & a_Input);
|
||||||
|
|
||||||
|
/** Escapes the string for use in an URL */
|
||||||
|
static AString GetURLEncodedString(const AString & a_Input);
|
||||||
|
|
||||||
AString GetIPv4Ports(void) const { return m_PortsIPv4; }
|
AString GetIPv4Ports(void) const { return m_PortsIPv4; }
|
||||||
AString GetIPv6Ports(void) const { return m_PortsIPv6; }
|
AString GetIPv6Ports(void) const { return m_PortsIPv6; }
|
||||||
|
|
||||||
// tolua_end
|
// tolua_end
|
||||||
|
|
||||||
/** Returns the prefix needed for making a link point to the webadmin root from the given URL ("../../../webadmin"-style) */
|
/** Returns the prefix needed for making a link point to the webadmin root from the given URL ("../../../webadmin"-style) */
|
||||||
AString GetBaseURL(const AStringVector& a_URLSplit);
|
static AString GetBaseURL(const AStringVector & a_URLSplit);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Common base class for request body data handlers */
|
/** Common base class for request body data handlers */
|
||||||
|
Loading…
Reference in New Issue
Block a user