From 5256d3a02e3f17c70cb1307929adbd9f6ea91432 Mon Sep 17 00:00:00 2001 From: Colin Leroy Date: Sun, 14 Nov 2004 19:14:35 +0000 Subject: [PATCH] 2004-11-14 [colin] 0.9.12cvs146.9 * src/textview.c Fix uri_security_check Patch by Alfons --- ChangeLog-gtk2.claws | 6 ++++ PATCHSETS | 1 + configure.ac | 2 +- src/textview.c | 75 ++++++-------------------------------------- 4 files changed, 17 insertions(+), 67 deletions(-) diff --git a/ChangeLog-gtk2.claws b/ChangeLog-gtk2.claws index 948c7521f..ed1c85eba 100644 --- a/ChangeLog-gtk2.claws +++ b/ChangeLog-gtk2.claws @@ -1,3 +1,9 @@ +2004-11-14 [colin] 0.9.12cvs146.9 + + * src/textview.c + Fix uri_security_check + Patch by Alfons + 2004-11-13 [paul] 0.9.12cvs146.8 * src/folder.c diff --git a/PATCHSETS b/PATCHSETS index 14979659b..6632d2919 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -233,3 +233,4 @@ ( cvs diff -u -r 1.382.2.62 -r 1.382.2.63 src/compose.c; cvs diff -u -r 1.179.2.12 -r 1.179.2.13 src/imap.c; cvs diff -u -r 1.4.2.2 -r 1.4.2.3 src/matcher_parser.h; cvs diff -u -r 1.25.2.5 -r 1.25.2.6 src/matcher_parser_parse.y; cvs diff -u -r 1.59.2.8 -r 1.59.2.9 src/prefs_filtering.c; cvs diff -u -r 1.1.4.7 -r 1.1.4.8 src/prefs_filtering_action.c; cvs diff -u -r 1.3.2.9 -r 1.3.2.10 src/prefs_themes.c; cvs diff -u -r 1.30.2.5 -r 1.30.2.6 src/prefs_toolbar.c; cvs diff -u -r 1.36.2.14 -r 1.36.2.15 src/common/utils.c; ) > 0.9.12cvs146.6.patchset ( cvs diff -u -r 1.382.2.63 -r 1.382.2.64 src/compose.c; cvs diff -u -r 1.5.2.3 -r 1.5.2.4 src/exporthtml.c; cvs diff -u -r 1.1.4.3 -r 1.1.4.4 src/exportldif.c; cvs diff -u -r 1.213.2.20 -r 1.213.2.21 src/folder.c; cvs diff -u -r 1.179.2.13 -r 1.179.2.14 src/imap.c; cvs diff -u -r 1.1.2.3 -r 1.1.2.4 src/imap_gtk.c; cvs diff -u -r 1.115.2.22 -r 1.115.2.23 src/main.c; cvs diff -u -r 1.274.2.23 -r 1.274.2.24 src/mainwindow.c; cvs diff -u -r 1.94.2.32 -r 1.94.2.33 src/messageview.c; cvs diff -u -r 1.2.2.3 -r 1.2.2.4 src/mh_gtk.c; cvs diff -u -r 1.3.2.10 -r 1.3.2.11 src/prefs_themes.c; cvs diff -u -r 1.49.2.19 -r 1.49.2.20 src/procmime.c; cvs diff -u -r 1.5.2.2 -r 1.5.2.3 src/setup.c; cvs diff -u -r 1.395.2.39 -r 1.395.2.40 src/summaryview.c; ) > 0.9.12cvs146.7.patchset ( cvs diff -u -r 1.213.2.21 -r 1.213.2.22 src/folder.c; cvs diff -u -r 1.49.2.20 -r 1.49.2.21 src/procmime.c; ) > 0.9.12cvs146.8.patchset +( cvs diff -u -r 1.96.2.34 -r 1.96.2.35 src/textview.c; ) > 0.9.12cvs146.9.patchset diff --git a/configure.ac b/configure.ac index 121e5a57f..e1b3c3f6a 100644 --- a/configure.ac +++ b/configure.ac @@ -13,7 +13,7 @@ INTERFACE_AGE=0 BINARY_AGE=0 EXTRA_VERSION=146 EXTRA_RELEASE= -EXTRA_GTK2_VERSION=.8 +EXTRA_GTK2_VERSION=.9 if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}${EXTRA_RELEASE}${EXTRA_GTK2_VERSION} diff --git a/src/textview.c b/src/textview.c index 9658e8f8c..ba97f5076 100644 --- a/src/textview.c +++ b/src/textview.c @@ -1824,70 +1824,6 @@ static gint textview_key_pressed(GtkWidget *widget, GdkEventKey *event, return TRUE; } -/*! - *\brief Check to see if a web URL has been disguised as a different - * URL (possible with HTML email). - * - *\param uri The uri to check - * - *\param textview The TextView the URL is contained in - * - *\return gboolean TRUE if the URL is ok, or if the user chose to open - * it anyway, otherwise FALSE - */ -static gboolean uri_security_check(RemoteURI *uri, TextView *textview) -{ - gchar *clicked_str; - gboolean retval = TRUE; - - if (g_ascii_strncasecmp(uri->uri, "http:", 5) && - g_ascii_strncasecmp(uri->uri, "https:", 6) && - g_ascii_strncasecmp(uri->uri, "www.", 4)) - return retval; - - clicked_str = gtk_editable_get_chars(GTK_EDITABLE(textview->text), - uri->start, - uri->end); - if (clicked_str == NULL) - return TRUE; - - if (strcmp(clicked_str, uri->uri) && - (!g_ascii_strncasecmp(clicked_str, "http:", 5) || - !g_ascii_strncasecmp(clicked_str, "https:", 6) || - !g_ascii_strncasecmp(clicked_str, "www.", 4))) { - gchar *str; - retval = FALSE; - - /* allow uri->uri == http://somewhere.com - and clicked_str == somewhere.com */ - str = g_strconcat("http://", clicked_str, NULL); - - if (!g_ascii_strcasecmp(str, uri->uri)) - retval = TRUE; - g_free(str); - } - - if (retval == FALSE) { - gchar *msg = NULL; - AlertValue resp; - - msg = g_strdup_printf(_("The real URL (%s) is different from\n" - "the apparent URL (%s). \n" - "Open it anyway?"), - uri->uri, clicked_str); - resp = alertpanel_with_type(_("Warning"), - msg, - _("Yes"), - _("No"), - NULL, NULL, ALERT_WARNING); - g_free(msg); - if (resp == G_ALERTDEFAULT) - retval = TRUE; - } - g_free(clicked_str); - return retval; -} - static gboolean textview_motion_notify(GtkWidget *widget, GdkEventMotion *event, TextView *textview) @@ -2163,12 +2099,19 @@ static gboolean textview_uri_security_check(TextView *textview, RemoteURI *uri) { gchar *visible_str; gboolean retval = TRUE; + GtkTextBuffer *buffer; + GtkTextIter start, end; if (is_uri_string(uri->uri) == FALSE) return TRUE; - visible_str = gtk_editable_get_chars(GTK_EDITABLE(textview->text), - uri->start, uri->end); + buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview->text)); + + gtk_text_buffer_get_iter_at_offset(buffer, &start, uri->start); + gtk_text_buffer_get_iter_at_offset(buffer, &end, uri->end); + + visible_str = gtk_text_buffer_get_text(buffer, &start, &end, FALSE); + if (visible_str == NULL) return TRUE; -- 2.25.1