diff options
author | Marco Pesenti Gritti <marco@gnome.org> | 2004-04-27 03:27:51 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2004-04-27 03:27:51 +0800 |
commit | 9095136a9ea233cd541c30a83a6db127fc6d6235 (patch) | |
tree | 4cb388afef0ab9061677e834c20f1550c1092a64 /embed/mozilla | |
parent | f568519bbaa93651cec4b1deaa532d62d3bec9e0 (diff) | |
download | gsoc2013-epiphany-9095136a9ea233cd541c30a83a6db127fc6d6235.tar gsoc2013-epiphany-9095136a9ea233cd541c30a83a6db127fc6d6235.tar.gz gsoc2013-epiphany-9095136a9ea233cd541c30a83a6db127fc6d6235.tar.bz2 gsoc2013-epiphany-9095136a9ea233cd541c30a83a6db127fc6d6235.tar.lz gsoc2013-epiphany-9095136a9ea233cd541c30a83a6db127fc6d6235.tar.xz gsoc2013-epiphany-9095136a9ea233cd541c30a83a6db127fc6d6235.tar.zst gsoc2013-epiphany-9095136a9ea233cd541c30a83a6db127fc6d6235.zip |
Fix encoding of saved content; fixes bug #141050.
2004-04-26 Marco Pesenti Gritti <marco@gnome.org>
* embed/mozilla/MozDownload.cpp:
Fix encoding of saved content; fixes bug #141050.
Diffstat (limited to 'embed/mozilla')
-rw-r--r-- | embed/mozilla/MozDownload.cpp | 57 |
1 files changed, 23 insertions, 34 deletions
diff --git a/embed/mozilla/MozDownload.cpp b/embed/mozilla/MozDownload.cpp index e548dd86b..722e7d8a5 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,51 +496,40 @@ 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 (" "); - nameMinusExt += NS_ConvertUTF8toUTF16 (_("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 (" "); + nameMinusExt += NS_ConvertUTF8toUTF16 (_("Files")); + + filesFolder->SetLeafName(nameMinusExt); + rv = webPersist->SaveDocument (domDocument, inDestFile, filesFolder, contentType, encodingFlags, 80); } |