diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2006-01-31 04:17:30 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2006-01-31 04:17:30 +0800 |
commit | 745ff820f8656ed82091b06af7c29e5a351b4277 (patch) | |
tree | 0e29ad25e57d5b9e4945da267dd7988e045f24bf /embed/mozilla | |
parent | a1f39ad0a4fb61c941496c7f64695d7eff797c34 (diff) | |
download | gsoc2013-epiphany-745ff820f8656ed82091b06af7c29e5a351b4277.tar gsoc2013-epiphany-745ff820f8656ed82091b06af7c29e5a351b4277.tar.gz gsoc2013-epiphany-745ff820f8656ed82091b06af7c29e5a351b4277.tar.bz2 gsoc2013-epiphany-745ff820f8656ed82091b06af7c29e5a351b4277.tar.lz gsoc2013-epiphany-745ff820f8656ed82091b06af7c29e5a351b4277.tar.xz gsoc2013-epiphany-745ff820f8656ed82091b06af7c29e5a351b4277.tar.zst gsoc2013-epiphany-745ff820f8656ed82091b06af7c29e5a351b4277.zip |
Truncate URI and title strings. Bug #329160.
2006-01-30 Christian Persch <chpe@cvs.gnome.org>
* embed/mozilla/GlobalHistory.cpp:
Truncate URI and title strings. Bug #329160.
Diffstat (limited to 'embed/mozilla')
-rw-r--r-- | embed/mozilla/GlobalHistory.cpp | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/embed/mozilla/GlobalHistory.cpp b/embed/mozilla/GlobalHistory.cpp index 909ce1de7..841fdf031 100644 --- a/embed/mozilla/GlobalHistory.cpp +++ b/embed/mozilla/GlobalHistory.cpp @@ -32,6 +32,9 @@ #include <nsEmbedString.h> #define MOZILLA_INTERNAL_API 1 +#define MAX_TITLE_LENGTH 2048 +#define MAX_URL_LENGTH 16384 + NS_IMPL_ISUPPORTS1 (MozGlobalHistory, nsIGlobalHistory2) MozGlobalHistory::MozGlobalHistory () @@ -98,6 +101,8 @@ NS_IMETHODIMP MozGlobalHistory::AddURI(nsIURI *aURI, rv = aURI->GetSpec(spec); NS_ENSURE_TRUE (NS_SUCCEEDED(rv) && spec.Length(), rv); + if (spec.Length () > MAX_URL_LENGTH) return NS_OK; + ephy_history_add_page (mGlobalHistory, spec.get(), aRedirect, aToplevel); return NS_OK; @@ -109,9 +114,13 @@ NS_IMETHODIMP MozGlobalHistory::IsVisited(nsIURI *aURI, { NS_ENSURE_ARG (aURI); + *_retval = PR_FALSE; + nsEmbedCString spec; aURI->GetSpec(spec); + if (spec.Length () > MAX_URL_LENGTH) return NS_OK; + *_retval = ephy_history_is_page_visited (mGlobalHistory, spec.get()); return NS_OK; @@ -123,15 +132,27 @@ NS_IMETHODIMP MozGlobalHistory::SetPageTitle(nsIURI *aURI, { NS_ENSURE_ARG (aURI); - nsEmbedCString title; - NS_UTF16ToCString (nsEmbedString (aTitle), - NS_CSTRING_ENCODING_UTF8, title); - nsEmbedCString spec; aURI->GetSpec(spec); - - ephy_history_set_page_title (mGlobalHistory, spec.get(), title.get()); - + + if (spec.Length () > MAX_URL_LENGTH) return NS_OK; + + nsEmbedString uTitle (aTitle); + + /* This depends on the assumption that + * typeof(PRUnichar) == typeof (gunichar2) == uint16, + * which should be pretty safe. + */ + glong n_read = 0, n_written = 0; + char *converted = g_utf16_to_utf8 ((gunichar2*) uTitle.get(), MAX_TITLE_LENGTH, + &n_read, &n_written, NULL); + /* FIXME loop from the end while !g_unichar_isspace (char)? */ + if (converted == NULL) return NS_OK; + + ephy_history_set_page_title (mGlobalHistory, spec.get(), converted); + + g_free (converted); + return NS_OK; } @@ -141,9 +162,13 @@ NS_IMETHODIMP MozGlobalHistory::GetURIGeckoFlags(nsIURI *aURI, PRUint32* aFlags) { + *aFlags = 0; + nsEmbedCString spec; aURI->GetSpec(spec); + if (spec.Length () > MAX_URL_LENGTH) return NS_OK; + EphyNode *page = ephy_history_get_page (mGlobalHistory, spec.get()); GValue value = { 0, }; @@ -167,6 +192,8 @@ MozGlobalHistory::SetURIGeckoFlags(nsIURI *aURI, nsEmbedCString spec; aURI->GetSpec(spec); + if (spec.Length () > MAX_URL_LENGTH) return NS_OK; + EphyNode *page = ephy_history_get_page (mGlobalHistory, spec.get()); if (page != NULL) { |