diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2004-05-30 03:17:20 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2004-05-30 03:17:20 +0800 |
commit | e5f48c33b6508d8ce7a930c2a76d1a3404e25f5d (patch) | |
tree | 4e9357ebbd66bfc92ce9354c57f5182b7ec0beb8 /embed/mozilla/GlobalHistory.cpp | |
parent | 67858e7918989ffd28bbe4e95f96d2e4fffe26a3 (diff) | |
download | gsoc2013-epiphany-e5f48c33b6508d8ce7a930c2a76d1a3404e25f5d.tar gsoc2013-epiphany-e5f48c33b6508d8ce7a930c2a76d1a3404e25f5d.tar.gz gsoc2013-epiphany-e5f48c33b6508d8ce7a930c2a76d1a3404e25f5d.tar.bz2 gsoc2013-epiphany-e5f48c33b6508d8ce7a930c2a76d1a3404e25f5d.tar.lz gsoc2013-epiphany-e5f48c33b6508d8ce7a930c2a76d1a3404e25f5d.tar.xz gsoc2013-epiphany-e5f48c33b6508d8ce7a930c2a76d1a3404e25f5d.tar.zst gsoc2013-epiphany-e5f48c33b6508d8ce7a930c2a76d1a3404e25f5d.zip |
Filter unwanted urls (unused protocols, redirects, non-toplevel loads).
2004-05-29 Christian Persch <chpe@cvs.gnome.org>
* embed/mozilla/GlobalHistory.cpp:
Filter unwanted urls (unused protocols, redirects, non-toplevel
loads). Should fix bug #142143.
Diffstat (limited to 'embed/mozilla/GlobalHistory.cpp')
-rw-r--r-- | embed/mozilla/GlobalHistory.cpp | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/embed/mozilla/GlobalHistory.cpp b/embed/mozilla/GlobalHistory.cpp index a612fb3b6..3cd801d37 100644 --- a/embed/mozilla/GlobalHistory.cpp +++ b/embed/mozilla/GlobalHistory.cpp @@ -50,8 +50,51 @@ MozGlobalHistory::~MozGlobalHistory () /* void addURI (in nsIURI aURI, in boolean aRedirect, in boolean aToplevel); */ NS_IMETHODIMP MozGlobalHistory::AddURI(nsIURI *aURI, PRBool aRedirect, PRBool aToplevel) { + nsresult rv; + NS_ENSURE_ARG_POINTER(aURI); + + PRBool isJavascript; + rv = aURI->SchemeIs("javascript", &isJavascript); + NS_ENSURE_SUCCESS(rv, rv); + + if (isJavascript || aRedirect || !aTopLevel) + { + return NS_OK; + } + + // filter out unwanted URIs such as chrome: etc + // The model is really if we don't know differently then add which basically + // means we are suppose to try all the things we know not to allow in and + // then if we don't bail go on and allow it in. But here lets compare + // against the most common case we know to allow in and go on and say yes + // to it. + + PRBool isHTTP = PR_FALSE; + PRBool isHTTPS = PR_FALSE; + + rv = aURI->SchemeIs("http", &isHTTP); + rv |= aURI->SchemeIs("https", &isHTTPS); + NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE); + + if (!isHTTP && !isHTTPS) + { + PRBool isAbout, isViewSource, isChrome, isData; + + rv = aURI->SchemeIs("about", &isAbout); + rv |= aURI->SchemeIs("view-source", &isViewSource); + rv |= aURI->SchemeIs("chrome", &isChrome); + rv |= aURI->SchemeIs("data", &isData); + NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); + + if (isAbout || isViewSource || isChrome || isData) + { + return NS_OK; + } + } + nsCAutoString spec; - aURI->GetSpec(spec); + rv = aURI->GetSpec(spec); + NS_ENSURE_SUCCESS(rv, rv); ephy_history_add_page (mGlobalHistory, spec.get()); @@ -61,6 +104,8 @@ NS_IMETHODIMP MozGlobalHistory::AddURI(nsIURI *aURI, PRBool aRedirect, PRBool aT /* boolean isVisited (in nsIURI aURI); */ NS_IMETHODIMP MozGlobalHistory::IsVisited(nsIURI *aURI, PRBool *_retval) { + NS_ENSURE_ARG_POINTER(aURI); + nsCAutoString spec; aURI->GetSpec(spec); @@ -72,6 +117,8 @@ NS_IMETHODIMP MozGlobalHistory::IsVisited(nsIURI *aURI, PRBool *_retval) /* void setPageTitle (in nsIURI aURI, in AString aTitle); */ NS_IMETHODIMP MozGlobalHistory::SetPageTitle(nsIURI *aURI, const nsAString & aTitle) { + NS_ENSURE_ARG_POINTER(aURI); + const nsACString &title = NS_ConvertUTF16toUTF8(aTitle); nsCAutoString spec; |