diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2004-04-27 03:21:34 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2004-04-27 03:21:34 +0800 |
commit | b5bca08846a76a89234a9dbe6219ad9bc6fc2abe (patch) | |
tree | 93c714ba62c0725f1af4a08b630ba453b40848bf /embed | |
parent | 128299b23fd69395667fe0ef0545493a64e13b44 (diff) | |
download | gsoc2013-epiphany-b5bca08846a76a89234a9dbe6219ad9bc6fc2abe.tar gsoc2013-epiphany-b5bca08846a76a89234a9dbe6219ad9bc6fc2abe.tar.gz gsoc2013-epiphany-b5bca08846a76a89234a9dbe6219ad9bc6fc2abe.tar.bz2 gsoc2013-epiphany-b5bca08846a76a89234a9dbe6219ad9bc6fc2abe.tar.lz gsoc2013-epiphany-b5bca08846a76a89234a9dbe6219ad9bc6fc2abe.tar.xz gsoc2013-epiphany-b5bca08846a76a89234a9dbe6219ad9bc6fc2abe.tar.zst gsoc2013-epiphany-b5bca08846a76a89234a9dbe6219ad9bc6fc2abe.zip |
Fix encoding of saved and downloaded content; fixes bug 141050.
2004-04-26 Christian Persch <chpe@cvs.gnome.org>
* embed/mozilla/MozDownload.cpp:
Fix encoding of saved and downloaded content; fixes bug 141050.
Diffstat (limited to 'embed')
-rw-r--r-- | embed/mozilla/MozDownload.cpp | 53 |
1 files changed, 21 insertions, 32 deletions
diff --git a/embed/mozilla/MozDownload.cpp b/embed/mozilla/MozDownload.cpp index a7b3660d0..473d81cfd 100644 --- a/embed/mozilla/MozDownload.cpp +++ b/embed/mozilla/MozDownload.cpp @@ -465,7 +465,7 @@ nsresult InitiateMozillaDownload (nsIDOMDocument *domDocument, nsIURI *sourceURI EmbedPersistFlags ephy_flags; ephy_flags = ephy_embed_persist_get_flags (EPHY_EMBED_PERSIST (embedPersist)); - PRBool isHTML = (domDocument && contentType && + PRBool isHTML = (contentType && (strcmp (contentType, "text/html") == 0 || strcmp (contentType, "text/xml") == 0 || strcmp (contentType, "application/xhtml+xml") == 0)); @@ -486,7 +486,7 @@ nsresult InitiateMozillaDownload (nsIDOMDocument *domDocument, nsIURI *sourceURI PRInt32 flags = nsIWebBrowserPersist::PERSIST_FLAGS_REPLACE_EXISTING_FILES; - if (!isHTML) + if (!domDocument && !isHTML && !(ephy_flags & EMBED_PERSIST_COPY_PAGE)) { flags |= nsIWebBrowserPersist::PERSIST_FLAGS_NO_CONVERSION; } @@ -496,49 +496,38 @@ nsresult InitiateMozillaDownload (nsIDOMDocument *domDocument, nsIURI *sourceURI } webPersist->SetPersistFlags(flags); - if (!isHTML || ephy_flags & EMBED_PERSIST_COPY_PAGE) + if (!domDocument || !isHTML || ephy_flags & EMBED_PERSIST_COPY_PAGE) { rv = webPersist->SaveURI (sourceURI, aCacheKey, nsnull, postData, nsnull, inDestFile); } else { - if (!domDocument) return rv; /* should never happen */ - PRInt32 encodingFlags = 0; nsCOMPtr<nsILocalFile> filesFolder; - if (!contentType || strcmp (contentType, "text/plain") != 0) - { - /** - * Construct a directory path to hold the associated files; mozilla - * will create the directory as needed. - */ - - filesFolder = do_CreateInstance("@mozilla.org/file/local;1"); - nsAutoString unicodePath; - inDestFile->GetPath(unicodePath); - filesFolder->InitWithPath(unicodePath); - - nsAutoString leafName; - filesFolder->GetLeafName(leafName); - nsAutoString nameMinusExt(leafName); - PRInt32 index = nameMinusExt.RFind("."); - if (index >= 0) - { - nameMinusExt.Left(nameMinusExt, index); - } + /** + * Construct a directory path to hold the associated files; mozilla + * will create the directory as needed. + */ - nameMinusExt += NS_LITERAL_STRING (" Files"); - filesFolder->SetLeafName(nameMinusExt); - } - else + filesFolder = do_CreateInstance("@mozilla.org/file/local;1"); + nsAutoString unicodePath; + inDestFile->GetPath(unicodePath); + filesFolder->InitWithPath(unicodePath); + + nsAutoString leafName; + filesFolder->GetLeafName(leafName); + nsAutoString nameMinusExt(leafName); + PRInt32 index = nameMinusExt.RFind("."); + if (index >= 0) { - encodingFlags |= nsIWebBrowserPersist::ENCODE_FLAGS_FORMATTED | - nsIWebBrowserPersist::ENCODE_FLAGS_ABSOLUTE_LINKS | - nsIWebBrowserPersist::ENCODE_FLAGS_NOFRAMES_CONTENT; + nameMinusExt.Left(nameMinusExt, index); } + nameMinusExt += NS_LITERAL_STRING (" Files"); + filesFolder->SetLeafName(nameMinusExt); + rv = webPersist->SaveDocument (domDocument, inDestFile, filesFolder, contentType, encodingFlags, 80); } |