From: Pieter Lexis Date: Wed, 2 Sep 2015 12:14:02 +0000 (+0200) Subject: Prevent XSS by escaping user input X-Git-Tag: dnsdist-1.0.0-alpha1~248^2~33^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c7f59d62064ccfb9f71e9db8b1e139b355310564;p=pdns Prevent XSS by escaping user input Additionally, escape "'s so no attributes can be inserted into webpages. Thanks to Pierre Jaury and Damien Cauquil at Sysdream for pointing this out. --- diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index 9ad8efebe..9629fb2cb 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -122,6 +122,9 @@ static string htmlescape(const string &s) { case '>': result += ">"; break; + case '"': + result += """; + break; default: result += *it; } @@ -141,15 +144,15 @@ void printtable(ostringstream &ret, const string &ringname, const string &title, } ret<<"
"; - ret<<"Reset"<Reset"<"<"<"; - ret<<"Showing: Top "<"<Showing: Top "<"<Resize: "; unsigned int sizes[]={10,100,500,1000,10000,500000,0}; for(int i=0;sizes[i];++i) { if(S.getRingSize(ringname)!=sizes[i]) - ret<<""< "; + ret<<""< "; else ret<<"("<