aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--embed/mozilla/GlobalHistory.cpp41
2 files changed, 40 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 0b317dbe1..4fa9cd54b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2006-01-30 Christian Persch <chpe@cvs.gnome.org>
+ * embed/mozilla/GlobalHistory.cpp:
+
+ Truncate URI and title strings. Bug #329160.
+
+2006-01-30 Christian Persch <chpe@cvs.gnome.org>
+
* src/ephy-find-toolbar.c: (ephy_find_toolbar_dispose),
(ephy_find_toolbar_class_init):
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)
{