Added a HTML escaping function to cWebAdmin.
Apparently my editor fixed some failed tabs too.
This commit is contained in:
parent
be996c1662
commit
9701a7fb84
@ -397,6 +397,45 @@ AString cWebAdmin::GetBaseURL( const AString& a_URL )
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AString cWebAdmin::GetHTMLEscapedString( const AString& a_Input )
|
||||||
|
{
|
||||||
|
|
||||||
|
// Define a stringstream to write the output to.
|
||||||
|
std::stringstream dst;
|
||||||
|
|
||||||
|
// Loop over input and substitute HTML characters for their alternatives.
|
||||||
|
for (char workingCharacter : a_Input) {
|
||||||
|
switch (workingCharacter)
|
||||||
|
{
|
||||||
|
case '&':
|
||||||
|
dst << "&";
|
||||||
|
break;
|
||||||
|
case '\'':
|
||||||
|
dst << "'";
|
||||||
|
break;
|
||||||
|
case '"':
|
||||||
|
dst << """;
|
||||||
|
break;
|
||||||
|
case '<':
|
||||||
|
dst << "<";
|
||||||
|
break;
|
||||||
|
case '>':
|
||||||
|
dst << ">";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
dst << workingCharacter;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dst.str();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AString cWebAdmin::GetBaseURL( const AStringVector& a_URLSplit )
|
AString cWebAdmin::GetBaseURL( const AStringVector& a_URLSplit )
|
||||||
{
|
{
|
||||||
AString BaseURL = "./";
|
AString BaseURL = "./";
|
||||||
|
@ -132,6 +132,9 @@ public:
|
|||||||
|
|
||||||
AString GetBaseURL(const AString& a_URL);
|
AString GetBaseURL(const AString& a_URL);
|
||||||
|
|
||||||
|
// Escapes text passed into it, so it can be embedded into html.
|
||||||
|
AString GetHTMLEscapedString( const AString& a_Input );
|
||||||
|
|
||||||
// tolua_end
|
// tolua_end
|
||||||
|
|
||||||
AString GetBaseURL(const AStringVector& a_URLSplit);
|
AString GetBaseURL(const AStringVector& a_URLSplit);
|
||||||
|
Loading…
Reference in New Issue
Block a user