Author: mhabersack
Date: 2007-09-28 06:23:25 -0400 (Fri, 28 Sep 2007)
New Revision: 86562
Modified:
trunk/mcs/class/System/System.Net.Mime/ChangeLog
trunk/mcs/class/System/System.Net.Mime/ContentDisposition.cs
Log:
2007-09-28 Marek Habersack <[EMAIL PROTECTED]>
* ContentDisposition.cs: if the file name contains spaces, enclose
it in quotes. Fixes bug #324084.
Modified: trunk/mcs/class/System/System.Net.Mime/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.Net.Mime/ChangeLog 2007-09-28 09:41:40 UTC
(rev 86561)
+++ trunk/mcs/class/System/System.Net.Mime/ChangeLog 2007-09-28 10:23:25 UTC
(rev 86562)
@@ -1,3 +1,8 @@
+2007-09-28 Marek Habersack <[EMAIL PROTECTED]>
+
+ * ContentDisposition.cs: if the file name contains spaces, enclose
+ it in quotes. Fixes bug #324084.
+
2006-01-13 John Luke <[EMAIL PROTECTED]>
* ContentDisposition.cs: use String.Compare instead
Modified: trunk/mcs/class/System/System.Net.Mime/ContentDisposition.cs
===================================================================
--- trunk/mcs/class/System/System.Net.Mime/ContentDisposition.cs
2007-09-28 09:41:40 UTC (rev 86561)
+++ trunk/mcs/class/System/System.Net.Mime/ContentDisposition.cs
2007-09-28 10:23:25 UTC (rev 86562)
@@ -212,19 +212,36 @@
// the content-disposition header as in RFC 2183
// ex. attachment; filename=genome.jpeg;
modification-date="Wed, 12 Feb 1997 16:29:51 -0500";
// the dates must be quoted and in RFC 822 format
+ //
+ // According to RFC 2183, the filename field value
follows the definition
+ // given in RFC 1521, which is
+ //
+ // value := token / quoted-string
+ //
StringBuilder sb = new StringBuilder ();
sb.Append (DispositionType.ToLower ());
if (Parameters != null && Parameters.Count > 0) {
+ bool quote = false;
+ string key, value;
+
foreach (DictionaryEntry pair in Parameters)
{
if (pair.Value != null &&
pair.Value.ToString ().Length > 0) {
sb.Append ("; ");
sb.Append (pair.Key);
sb.Append ("=");
- if (pair.Key.ToString
().EndsWith ("date"))
+
+ key = pair.Key.ToString ();
+ value = pair.Value.ToString ();
+ if ((key == "filename" &&
value.IndexOf (' ') != -1) || key.EndsWith ("date"))
+ quote = true;
+ else
+ quote = false;
+
+ if (quote)
sb.Append ("\"");
- sb.Append (pair.Value);
- if (pair.Key.ToString
().EndsWith ("date"))
+ sb.Append (value);
+ if (quote)
sb.Append ("\"");
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches