Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUnderground78 <underground78@users.sourceforge.net>2012-11-18 02:35:50 +0400
committerUnderground78 <underground78@users.sourceforge.net>2012-11-18 02:35:50 +0400
commit716331e73d8d1de37328e880bf7206ada259f0fc (patch)
treea1840a44ccfb019f9b149ce55c1d60178aabc570 /src/DSUtil/text.cpp
parentb75f6c5b84a32adfec33717a98c7b4f33c5fe1bf (diff)
Web server: Escape the user inputs to avoid XSS exploits.
This commit partially fixes ticket #2729.
Diffstat (limited to 'src/DSUtil/text.cpp')
-rw-r--r--src/DSUtil/text.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/DSUtil/text.cpp b/src/DSUtil/text.cpp
index c5a2f829c..f4226ac1a 100644
--- a/src/DSUtil/text.cpp
+++ b/src/DSUtil/text.cpp
@@ -169,6 +169,19 @@ CString ExtractTag(CString tag, CMapStringToString& attribs, bool& fClosing)
return type;
}
+CStringA HtmlSpecialChars(CStringA str, bool bQuotes /*= false*/)
+{
+ str.Replace("&", "&amp;");
+ str.Replace("\"", "&quot;");
+ if (bQuotes) {
+ str.Replace("\'", "&#039;");
+ }
+ str.Replace("<", "&lt;");
+ str.Replace(">", "&gt;");
+
+ return str;
+}
+
CAtlList<CString>& MakeLower(CAtlList<CString>& sl)
{
POSITION pos = sl.GetHeadPosition();