aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-François Rameau <jframeau@cvs.gnome.org>2006-06-02 03:35:32 +0800
committerJean-François Rameau <jframeau@src.gnome.org>2006-06-02 03:35:32 +0800
commitae4e4736818f442abd435274cb3b75f8da02ad33 (patch)
treee552affa908143effd9f1fba8993eaa8ecf4e5f6
parent5d471eec3390f8f188037ac6a3c87a59aa77ec8e (diff)
downloadgsoc2013-epiphany-ae4e4736818f442abd435274cb3b75f8da02ad33.tar
gsoc2013-epiphany-ae4e4736818f442abd435274cb3b75f8da02ad33.tar.gz
gsoc2013-epiphany-ae4e4736818f442abd435274cb3b75f8da02ad33.tar.bz2
gsoc2013-epiphany-ae4e4736818f442abd435274cb3b75f8da02ad33.tar.lz
gsoc2013-epiphany-ae4e4736818f442abd435274cb3b75f8da02ad33.tar.xz
gsoc2013-epiphany-ae4e4736818f442abd435274cb3b75f8da02ad33.tar.zst
gsoc2013-epiphany-ae4e4736818f442abd435274cb3b75f8da02ad33.zip
Don't set cookies from favicon downloads. Bug #337835.
2006-06-01 Jean-François Rameau <jframeau@cvs.gnome.org> * embed/ephy-embed-persist.h: * embed/ephy-favicon-cache.c: (ephy_favicon_cache_download): * embed/mozilla/EphySingle.cpp: (Init, Detach, ExamineCookies, ExamineResponse, ExamineRequest, Observe): * embed/mozilla/EphySingle.h: * embed/mozilla/MozDownload.cpp: (InitiateMozillaDownload): Don't set cookies from favicon downloads. Bug #337835.
-rw-r--r--ChangeLog11
-rw-r--r--embed/ephy-embed-persist.h3
-rw-r--r--embed/ephy-favicon-cache.c4
-rw-r--r--embed/mozilla/EphySingle.cpp51
-rw-r--r--embed/mozilla/EphySingle.h5
-rw-r--r--embed/mozilla/MozDownload.cpp19
6 files changed, 87 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index ad1ab4930..31ba3bc57 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2006-06-01 Jean-François Rameau <jframeau@cvs.gnome.org>
+
+ * embed/ephy-embed-persist.h:
+ * embed/ephy-favicon-cache.c: (ephy_favicon_cache_download):
+ * embed/mozilla/EphySingle.cpp:
+ (Init, Detach, ExamineCookies, ExamineResponse, ExamineRequest, Observe):
+ * embed/mozilla/EphySingle.h:
+ * embed/mozilla/MozDownload.cpp: (InitiateMozillaDownload):
+
+ Don't set cookies from favicon downloads. Bug #337835.
+
2006-05-30 Frederic Peters <fpeters@0d.be>
* src/pdm-dialog.c: (pdm_dialog_cookies_construct):
diff --git a/embed/ephy-embed-persist.h b/embed/ephy-embed-persist.h
index 8e60841a3..120104f67 100644
--- a/embed/ephy-embed-persist.h
+++ b/embed/ephy-embed-persist.h
@@ -50,7 +50,8 @@ typedef enum
EPHY_EMBED_PERSIST_ASK_DESTINATION = 1 << 3,
EPHY_EMBED_PERSIST_DO_CONVERSION = 1 << 4,
EPHY_EMBED_PERSIST_FROM_CACHE = 1 << 5,
- EPHY_EMBED_PERSIST_NO_CERTDIALOGS = 1 << 6
+ EPHY_EMBED_PERSIST_NO_CERTDIALOGS = 1 << 6,
+ EPHY_EMBED_PERSIST_NO_COOKIES = 1 << 7
} EphyEmbedPersistFlags;
struct _EphyEmbedPersist
diff --git a/embed/ephy-favicon-cache.c b/embed/ephy-favicon-cache.c
index 9c9e81bf2..6c063bfbd 100644
--- a/embed/ephy-favicon-cache.c
+++ b/embed/ephy-favicon-cache.c
@@ -553,7 +553,9 @@ ephy_favicon_cache_download (EphyFaviconCache *cache,
ephy_embed_persist_set_dest (persist, dest);
ephy_embed_persist_set_flags (persist, EPHY_EMBED_PERSIST_NO_VIEW |
EPHY_EMBED_PERSIST_NO_CERTDIALOGS |
- EPHY_EMBED_PERSIST_DO_CONVERSION);
+ EPHY_EMBED_PERSIST_DO_CONVERSION |
+ EPHY_EMBED_PERSIST_NO_COOKIES
+ );
ephy_embed_persist_set_max_size (persist, EPHY_FAVICON_MAX_SIZE);
ephy_embed_persist_set_source (persist, favicon_url);
diff --git a/embed/mozilla/EphySingle.cpp b/embed/mozilla/EphySingle.cpp
index e6e82a4f6..ec8eb0b84 100644
--- a/embed/mozilla/EphySingle.cpp
+++ b/embed/mozilla/EphySingle.cpp
@@ -27,9 +27,12 @@
#include <nsICookie.h>
#include <nsICookie2.h>
#include <nsICookieManager.h>
+#include <nsIHttpChannel.h>
#include <nsIObserverService.h>
#include <nsIPermission.h>
#include <nsIPermissionManager.h>
+#include <nsIPropertyBag2.h>
+#include <nsIServiceManager.h>
#include <nsIURI.h>
#include <nsServiceManagerUtils.h>
#include <nsWeakReference.h>
@@ -63,6 +66,8 @@ EphySingle::Init (EphyEmbedSingle *aOwner)
rv |= mObserverService->AddObserver (this, "perm-changed", PR_FALSE);
rv |= mObserverService->AddObserver (this, "network:offline-status-changed", PR_FALSE);
rv |= mObserverService->AddObserver (this, "signonChanged", PR_FALSE);
+ rv |= mObserverService->AddObserver (this, "http-on-examine-response", PR_FALSE);
+ rv |= mObserverService->AddObserver (this, "http-on-modify-request", PR_FALSE);
NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
mOwner = aOwner;
@@ -84,6 +89,8 @@ EphySingle::Detach ()
mObserverService->RemoveObserver (this, "perm-changed");
mObserverService->RemoveObserver (this, "signonChanged");
mObserverService->RemoveObserver (this, "network:offline-status-changed");
+ mObserverService->RemoveObserver (this, "http-on-examine-response");
+ mObserverService->RemoveObserver (this, "http-on-modify-request");
#if 1
/* HACK: Work around https://bugzilla.mozilla.org/show_bug.cgi?id=292699 */
@@ -138,6 +145,40 @@ EphySingle::EmitPermissionNotification (const char *name,
return NS_OK;
}
+nsresult
+EphySingle::ExamineCookies (nsISupports *aSubject)
+{
+ nsCOMPtr<nsIPropertyBag2> props = do_QueryInterface(aSubject);
+ NS_ENSURE_TRUE (props, NS_ERROR_FAILURE);
+
+ PRBool isBlockingCookiesChannel = PR_FALSE;
+ props->GetPropertyAsBool(
+ NS_LITERAL_STRING("epiphany-blocking-cookies"),
+ &isBlockingCookiesChannel);
+ if (isBlockingCookiesChannel)
+ {
+ nsCOMPtr<nsIHttpChannel> channel = do_QueryInterface(aSubject);
+ NS_ENSURE_TRUE (channel, NS_ERROR_FAILURE);
+
+ channel->SetRequestHeader(NS_LITERAL_CSTRING("Cookie"),
+ EmptyCString(), PR_FALSE);
+ }
+
+ return NS_OK;
+}
+
+nsresult
+EphySingle::ExamineResponse (nsISupports *aSubject)
+{
+ return ExamineCookies (aSubject);
+}
+
+nsresult
+EphySingle::ExamineRequest (nsISupports *aSubject)
+{
+ return ExamineCookies (aSubject);
+}
+
/* void observe (in nsISupports aSubject, in string aTopic, in wstring aData); */
NS_IMETHODIMP EphySingle::Observe(nsISupports *aSubject,
const char *aTopic,
@@ -147,7 +188,15 @@ NS_IMETHODIMP EphySingle::Observe(nsISupports *aSubject,
LOG ("EphySingle::Observe topic %s", aTopic);
- if (strcmp (aTopic, "cookie-changed") == 0)
+ if (strcmp (aTopic, "http-on-examine-response") == 0)
+ {
+ rv = ExamineResponse (aSubject);
+ }
+ else if (strcmp (aTopic, "http-on-modify-request") == 0)
+ {
+ rv = ExamineRequest (aSubject);
+ }
+ else if (strcmp (aTopic, "cookie-changed") == 0)
{
/* "added" */
if (aData[0] == 'a')
diff --git a/embed/mozilla/EphySingle.h b/embed/mozilla/EphySingle.h
index c5dcaca53..c2a199e1c 100644
--- a/embed/mozilla/EphySingle.h
+++ b/embed/mozilla/EphySingle.h
@@ -50,7 +50,10 @@ public:
protected:
nsresult EmitCookieNotification (const char *name, nsISupports *aSubject);
nsresult EmitPermissionNotification (const char *name, nsISupports *aSubject);
-
+ nsresult ExamineResponse (nsISupports *aSubject);
+ nsresult ExamineRequest (nsISupports *aSubject);
+ nsresult ExamineCookies (nsISupports *aSubject);
+
private:
nsCOMPtr<nsIObserverService> mObserverService;
EphyEmbedSingle *mOwner;
diff --git a/embed/mozilla/MozDownload.cpp b/embed/mozilla/MozDownload.cpp
index 39fd8ee22..5c8ee71ec 100644
--- a/embed/mozilla/MozDownload.cpp
+++ b/embed/mozilla/MozDownload.cpp
@@ -52,6 +52,7 @@
#include <nsComponentManagerUtils.h>
#include <nsICancelable.h>
+#include <nsIChannel.h>
#include <nsIDOMDocument.h>
#include <nsIFileURL.h>
#include <nsIIOService.h>
@@ -60,8 +61,9 @@
#include <nsIObserver.h>
#include <nsIRequest.h>
#include <nsIURI.h>
-#include <nsIURI.h>
+#include <nsIWritablePropertyBag2.h>
#include <nsIWebBrowserPersist.h>
+
#include <nsMemory.h>
#include <nsNetError.h>
#include <nsServiceManagerUtils.h>
@@ -558,7 +560,20 @@ nsresult InitiateMozillaDownload (nsIDOMDocument *domDocument, nsIURI *sourceURI
}
webPersist->SetPersistFlags(flags);
- if (!domDocument || !isHTML || ephy_flags & EPHY_EMBED_PERSIST_COPY_PAGE)
+ /* Create a new tagged channel if we need to block cookies from server */
+ if (ephy_flags & EPHY_EMBED_PERSIST_NO_COOKIES)
+ {
+ nsCOMPtr<nsIChannel> tmpChannel;
+ rv = ioService->NewChannelFromURI (sourceURI, getter_AddRefs (tmpChannel));
+ NS_ENSURE_SUCCESS (rv, rv);
+
+ nsCOMPtr<nsIWritablePropertyBag2> props = do_QueryInterface(tmpChannel);
+ rv = props->SetPropertyAsBool (NS_LITERAL_STRING("epiphany-blocking-cookies"), PR_TRUE);
+ NS_ENSURE_SUCCESS (rv, rv);
+
+ rv = webPersist->SaveChannel (tmpChannel, inDestFile);
+ }
+ else if (!domDocument || !isHTML || ephy_flags & EPHY_EMBED_PERSIST_COPY_PAGE)
{
rv = webPersist->SaveURI (sourceURI, aCacheKey, nsnull,
postData, nsnull, inDestFile);