Merge branch 'htmlescape'.
This commit is contained in:
commit
0258213d24
@ -1785,7 +1785,10 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa
|
|||||||
cWebAdmin =
|
cWebAdmin =
|
||||||
{
|
{
|
||||||
Desc = "",
|
Desc = "",
|
||||||
Functions = {},
|
Functions =
|
||||||
|
{
|
||||||
|
GetHTMLEscapedString = { Params = "string", Return = "string", Notes = "Gets the HTML escaped representation of a requested string. This is useful for user input and game data that is not guaranteed to be escaped already." },
|
||||||
|
},
|
||||||
Constants = {},
|
Constants = {},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -397,7 +397,38 @@ AString cWebAdmin::GetBaseURL( const AString& a_URL )
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
AString cWebAdmin::GetBaseURL( const AStringVector& a_URLSplit )
|
AString cWebAdmin::GetHTMLEscapedString(const AString & a_Input)
|
||||||
|
{
|
||||||
|
AString dst;
|
||||||
|
dst.reserve(a_Input.length());
|
||||||
|
|
||||||
|
// Loop over input and substitute HTML characters for their alternatives:
|
||||||
|
size_t len = a_Input.length();
|
||||||
|
for (size_t i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
switch (a_Input[i])
|
||||||
|
{
|
||||||
|
case '&': dst.append("&"); break;
|
||||||
|
case '\'': dst.append("'"); break;
|
||||||
|
case '"': dst.append("""); break;
|
||||||
|
case '<': dst.append("<"); break;
|
||||||
|
case '>': dst.append(">"); break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
dst.push_back(a_Input[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} // switch (a_Input[i])
|
||||||
|
} // for i - a_Input[]
|
||||||
|
|
||||||
|
return dst;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AString cWebAdmin::GetBaseURL(const AStringVector & a_URLSplit)
|
||||||
{
|
{
|
||||||
AString BaseURL = "./";
|
AString BaseURL = "./";
|
||||||
if (a_URLSplit.size() > 1)
|
if (a_URLSplit.size() > 1)
|
||||||
|
@ -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