[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sup-devel] [PATCH] RFC 2231: value encoding for Content-Disposition



[Please, comment on this one and fill in the blank...]

RFC 2231 defines extensions to RFC 2183 disposition parameter
value mechanisms to provide value character set information
(http://greenbytes.de/tech/webdav/rfc2231.html#rfc.section.4),
e.g.:
    Content-Disposition: attachment; filename*=UTF-8''foo-%c3%a4-%e2%82%ac.html

The following pattern detects the cases described in 
http://greenbytes.de/tech/tc2231/#encoding-2231-char
(RFC2231 Encoding: Character Sets).

TODO: The value of filename ($2) must be decoded according to
the encoding specified in $1.

---
 lib/sup/message.rb |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/lib/sup/message.rb b/lib/sup/message.rb
index cf0e505..0b42f75 100644
--- a/lib/sup/message.rb
+++ b/lib/sup/message.rb
@@ -480,6 +480,17 @@ private
         ## separated by ";". So, we match everything up to " and ; (if present).
         if m.header["Content-Disposition"] && m.header["Content-Disposition"] =~ /filename="?(.*?[^\\])("|;|\z)/m
           $1
+        elsif m.header["Content-Disposition"] && m.header["Content-Disposition"] =~ /filename\*=(.*)''(.*)("|;|$)/
+          ## RFC 2231 defines extensions to RFC 2183 disposition parameter
+          ## value mechanisms to provide value character set information
+          ## (http://greenbytes.de/tech/webdav/rfc2231.html#rfc.section.4),
+          ## e.g.:
+          ##     Content-Disposition: attachment; filename*=UTF-8''foo-%c3%a4-%e2%82%ac.html
+          ##
+          ## The following pattern detects the cases described in 
+          ## http://greenbytes.de/tech/tc2231/#encoding-2231-char
+          ## (RFC2231 Encoding: Character Sets).
+          ##
+          ## TODO: The value of filename ($2) must be decoded according to
+          ## the encoding specified in $1.
+          $2
         elsif m.header["Content-Type"] && m.header["Content-Type"] =~ /name="?(.*?[^\\])("|;|\z)/im
           $1
--
1.5.6.5
 
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel