aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-02-29 21:21:53 +0800
committerChristian Persch <chpe@src.gnome.org>2004-02-29 21:21:53 +0800
commitb739c9c7b5cdf56705049b9fd5e9d745b7c3d1e6 (patch)
treee6fa5c970cbbceb86dbd9c38bb419aaa0c48d18e
parente384714845c1bd7a98dc2a3652a7192423e96bb6 (diff)
downloadgsoc2013-epiphany-b739c9c7b5cdf56705049b9fd5e9d745b7c3d1e6.tar
gsoc2013-epiphany-b739c9c7b5cdf56705049b9fd5e9d745b7c3d1e6.tar.gz
gsoc2013-epiphany-b739c9c7b5cdf56705049b9fd5e9d745b7c3d1e6.tar.bz2
gsoc2013-epiphany-b739c9c7b5cdf56705049b9fd5e9d745b7c3d1e6.tar.lz
gsoc2013-epiphany-b739c9c7b5cdf56705049b9fd5e9d745b7c3d1e6.tar.xz
gsoc2013-epiphany-b739c9c7b5cdf56705049b9fd5e9d745b7c3d1e6.tar.zst
gsoc2013-epiphany-b739c9c7b5cdf56705049b9fd5e9d745b7c3d1e6.zip
Decode RFC 2231 and RFC 2047 encoded filenames in content-disposition
2004-02-29 Christian Persch <chpe@cvs.gnome.org> * embed/mozilla/EphyHeaderSniffer.cpp: (PerformSave): Decode RFC 2231 and RFC 2047 encoded filenames in content-disposition headers. Ported from mozilla Camino, see http://bugzilla.mozilla.org/show_bug.cgi?id=233798 .
-rw-r--r--ChangeLog8
-rw-r--r--embed/mozilla/EphyHeaderSniffer.cpp40
2 files changed, 48 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 5b81ee4d9..96c1722ab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2004-02-29 Christian Persch <chpe@cvs.gnome.org>
+ * embed/mozilla/EphyHeaderSniffer.cpp: (PerformSave):
+
+ Decode RFC 2231 and RFC 2047 encoded filenames in content-disposition
+ headers. Ported from mozilla Camino, see
+ http://bugzilla.mozilla.org/show_bug.cgi?id=233798 .
+
+2004-02-29 Christian Persch <chpe@cvs.gnome.org>
+
* embed/mozilla/MozDownload.cpp: (MozDownload), (~MozDownload):
Add debug output.
diff --git a/embed/mozilla/EphyHeaderSniffer.cpp b/embed/mozilla/EphyHeaderSniffer.cpp
index c9240c1b3..35af9763f 100644
--- a/embed/mozilla/EphyHeaderSniffer.cpp
+++ b/embed/mozilla/EphyHeaderSniffer.cpp
@@ -67,6 +67,9 @@
#include "nsIMIMEInfo.h"
#include "nsIDOMHTMLDocument.h"
#include "nsIDownload.h"
+#if MOZILLA_SNAPSHOT > 10
+#include "nsIMIMEHeaderParam.h"
+#endif
#include <glib/gi18n.h>
#include <libgnomevfs/gnome-vfs-utils.h>
@@ -242,6 +245,36 @@ nsresult EphyHeaderSniffer::PerformSave (nsIURI* inOriginalURI)
if (defaultFileName.IsEmpty() && !mContentDisposition.IsEmpty())
{
/* 1 Use the HTTP header suggestion. */
+#if MOZILLA_SNAPSHOT > 10
+ nsCOMPtr<nsIMIMEHeaderParam> mimehdrpar =
+ do_GetService("@mozilla.org/network/mime-hdrparam;1");
+
+ if (mimehdrpar)
+ {g_print ("Using nsIMIMEHeaderParam!\n");
+ nsCAutoString fallbackCharset;
+ if (mURL)
+ {
+ mURL->GetOriginCharset(fallbackCharset);
+ }
+
+ nsAutoString fileName;
+
+ rv = mimehdrpar->GetParameter (mContentDisposition, "filename",
+ fallbackCharset, PR_TRUE, nsnull,
+ fileName);
+ if (NS_FAILED(rv) || fileName.IsEmpty())
+ {
+ rv = mimehdrpar->GetParameter (mContentDisposition, "name",
+ fallbackCharset, PR_TRUE, nsnull,
+ fileName);
+ }
+
+ if (NS_SUCCEEDED(rv) && !fileName.IsEmpty())
+ {
+ defaultFileName = fileName;
+ }
+ }
+#else
PRInt32 index = mContentDisposition.Find("filename=");
if (index >= 0)
{
@@ -251,6 +284,7 @@ nsresult EphyHeaderSniffer::PerformSave (nsIURI* inOriginalURI)
mContentDisposition.Right(filename, mContentDisposition.Length() - index);
defaultFileName = NS_ConvertUTF8toUCS2(filename);
}
+#endif
}
if (defaultFileName.IsEmpty())
@@ -262,6 +296,9 @@ nsresult EphyHeaderSniffer::PerformSave (nsIURI* inOriginalURI)
{
nsCAutoString fileNameCString;
url->GetFileName(fileNameCString);
+ /* FIXME: when we can depend on moz >= 1.5, use
+ * CopyUTF8toUTF16 instead
+ */
defaultFileName = NS_ConvertUTF8toUCS2(fileNameCString);
}
}
@@ -282,6 +319,9 @@ nsresult EphyHeaderSniffer::PerformSave (nsIURI* inOriginalURI)
/* 4 Use the host. */
nsCAutoString hostName;
mURL->GetHost(hostName);
+ /* FIXME: when we can depend on moz >= 1.5, use
+ * CopyUTF8toUTF16 instead
+ */
defaultFileName = NS_ConvertUTF8toUCS2(hostName);
}