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

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>2009-07-23 06:57:21 +0400
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>2009-07-23 06:57:21 +0400
commitce35b7094a7c5f81c9fd0f85b0fb51d82aaa4871 (patch)
tree6884fa7952813f9b3d2072d15bc65e98b5512d72 /mcs/class/System
parent488831bf7720ea1d793c51fd166c35a30275d256 (diff)
2009-07-22 Gonzalo Paniagua Javier <gonzalo@novell.com>
* WebHeaderCollection.cs: check the validity of the characters in the header names. svn path=/trunk/mcs/; revision=138485
Diffstat (limited to 'mcs/class/System')
-rw-r--r--mcs/class/System/System.Net/ChangeLog5
-rw-r--r--mcs/class/System/System.Net/WebHeaderCollection.cs34
2 files changed, 25 insertions, 14 deletions
diff --git a/mcs/class/System/System.Net/ChangeLog b/mcs/class/System/System.Net/ChangeLog
index 86b391ca61d..61810bfcfdc 100644
--- a/mcs/class/System/System.Net/ChangeLog
+++ b/mcs/class/System/System.Net/ChangeLog
@@ -1,5 +1,10 @@
2009-07-22 Gonzalo Paniagua Javier <gonzalo@novell.com>
+ * WebHeaderCollection.cs: check the validity of the characters in the
+ header names.
+
+2009-07-22 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
* WebHeaderCollection.cs: implemente the 2.0 IsRestricted().
2009-07-22 Gonzalo Paniagua Javier <gonzalo@novell.com>
diff --git a/mcs/class/System/System.Net/WebHeaderCollection.cs b/mcs/class/System/System.Net/WebHeaderCollection.cs
index f34248a02ea..9c4e94ceabc 100644
--- a/mcs/class/System/System.Net/WebHeaderCollection.cs
+++ b/mcs/class/System/System.Net/WebHeaderCollection.cs
@@ -257,6 +257,9 @@ namespace System.Net
if (headerName == "") // MS throw nullexception here!
throw new ArgumentException ("empty string", "headerName");
+ if (!IsHeaderName (headerName))
+ throw new ArgumentException ("Invalid character in header");
+
return restricted.ContainsKey (headerName);
}
@@ -266,6 +269,10 @@ namespace System.Net
if (String.IsNullOrEmpty (headerName))
throw new ArgumentNullException ("headerName");
+ if (!IsHeaderName (headerName))
+ throw new ArgumentException ("Invalid character in header");
+
+
if (response)
return restricted_response.ContainsKey (headerName);
return restricted.ContainsKey (headerName);
@@ -681,31 +688,30 @@ namespace System.Net
internal static bool IsHeaderName (string name)
{
- // token = 1*<any CHAR except CTLs or tspecials>
- // tspecials = "(" | ")" | "<" | ">" | "@"
- // | "," | ";" | ":" | "\" | <">
- // | "/" | "[" | "]" | "?" | "="
- // | "{" | "}" | SP | HT
-
if (name == null || name.Length == 0)
return false;
int len = name.Length;
for (int i = 0; i < len; i++) {
char c = name [i];
- if (c < 0x20 || c >= 0x7f)
+ if (c > 126 || !allowed_chars [(int) c])
return false;
}
- return name.IndexOfAny (tspecials) == -1;
+ return true;
}
- private static char [] tspecials =
- new char [] {'(', ')', '<', '>', '@',
- ',', ';', ':', '\\', '"',
- '/', '[', ']', '?', '=',
- '{', '}', ' ', '\t'};
-
+ static bool [] allowed_chars = new bool [126] {
+ false, false, false, false, false, false, false, false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false, false, false, false, false, false, false,
+ false, false, false, false, false, true, false, true, true, true, true, false, false, false, true,
+ true, false, true, true, false, true, true, true, true, true, true, true, true, true, true, false,
+ false, false, false, false, false, false, true, true, true, true, true, true, true, true, true,
+ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
+ false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true,
+ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
+ false, true, false
+ };
}
}