Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Security fix for bug #418620

svn path=/branches/mono-1-1-18/mcs/; revision=111117
  • Loading branch information...
commit 6e5c0bdf9e87faa44742dfaa369230b72e962630 1 parent 4f5502c
@grendello grendello authored
View
6 mcs/class/System.Web/System.Web/ChangeLog
@@ -1,3 +1,9 @@
+2008-08-20 Marek Habersack <mhabersack@novell.com>
+
+ * HttpResponseHeader.cs: encode header values in the 2.0 profile
+ if httpRuntime.enableHeaderChecking is true (default). Fixes bug
+ #418620
+
2006-10-09 Marek Habersack <grendello@gmail.com>
* HttpApplication.cs: change the pipeline order for ASP.NET 2.0 to
View
49 mcs/class/System.Web/System.Web/HttpResponseHeader.cs
@@ -30,17 +30,64 @@
using System.Collections;
using System.Text;
+using System.Web.Configuration;
namespace System.Web {
internal abstract class BaseResponseHeader {
- public string Value;
+ string headerValue;
+
+ public string Value {
+ get { return headerValue; }
+ set { headerValue = EncodeHeader (value); }
+ }
+#if NET_2_0
+ static bool headerCheckingEnabled;
+
+ static BaseResponseHeader () {
+ HttpRuntimeSection section = WebConfigurationManager.GetSection ("system.web/httpRuntime") as HttpRuntimeSection;
+ headerCheckingEnabled = section == null || section.EnableHeaderChecking;
+ }
+#endif
+
internal BaseResponseHeader (string val)
{
Value = val;
}
+ string EncodeHeader (string value)
+ {
+#if NET_2_0
+ if (String.IsNullOrEmpty (value))
+ return value;
+
+ if (headerCheckingEnabled) {
+ StringBuilder ret = new StringBuilder ();
+ int len = value.Length;
+
+ for (int i = 0; i < len; i++) {
+ switch (value [i]) {
+ case '\r':
+ ret.Append ("%0d");
+ break;
+
+ case '\n':
+ ret.Append ("%0a");
+ break;
+
+ default:
+ ret.Append (value [i]);
+ break;
+ }
+ }
+
+ return ret.ToString ();
+ } else
+#endif
+ return value;
+ }
+
internal abstract void SendContent (HttpWorkerRequest wr);
}
Please sign in to comment.
Something went wrong with that request. Please try again.