changeset 10240:95ca0db2d01d

[gaim-migrate @ 11377] Removing trust parameter for gaim_notify_uri (see gaim-devel over past few days). Removed URI scheme filtering for win32. Instead we'll allow what ever the default http browser allows. committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Mon, 22 Nov 2004 22:13:12 +0000
parents d0558652e0c4
children 1d67ab57abb2
files src/gtkblist.c src/gtknotify.c src/gtkutils.c src/notify.c src/notify.h src/protocols/jabber/jabber.c src/protocols/msn/notification.c src/protocols/oscar/oscar.c src/protocols/trepia/trepia.c src/protocols/yahoo/yahoo.c src/win32/win32dep.c src/win32/win32dep.h
diffstat 12 files changed, 38 insertions(+), 59 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkblist.c	Mon Nov 22 21:56:46 2004 +0000
+++ b/src/gtkblist.c	Mon Nov 22 22:13:12 2004 +0000
@@ -601,7 +601,7 @@
 
 static void gtk_blist_show_onlinehelp_cb()
 {
-	gaim_notify_uri(NULL, GAIM_WEBSITE "documentation.php", TRUE);
+	gaim_notify_uri(NULL, GAIM_WEBSITE "documentation.php");
 }
 
 static void
--- a/src/gtknotify.c	Mon Nov 22 21:56:46 2004 +0000
+++ b/src/gtknotify.c	Mon Nov 22 22:13:12 2004 +0000
@@ -62,7 +62,7 @@
 email_response_cb(GtkDialog *dialog, gint id, GaimNotifyMailData *data)
 {
 	if (id == 0)
-		gaim_notify_uri(NULL, data->url, TRUE);
+		gaim_notify_uri(NULL, data->url);
 
 	gaim_notify_close(GAIM_NOTIFY_EMAILS, data);
 }
@@ -454,7 +454,7 @@
 #endif /* _WIN32 */
 
 static void *
-gaim_gtk_notify_uri(const char *uri, gboolean trusted)
+gaim_gtk_notify_uri(const char *uri)
 {
 #ifndef _WIN32
 	char *command = NULL;
@@ -598,27 +598,7 @@
 	g_free(command);
 
 #else /* !_WIN32 */
-	/**
-	 * If the URI is not trusted we limit ourselves to the following URI
-	 * types (Execution of an untrusted local file URI could potentially
-	 * be a security risk):
-	 * http, https, ftp, mailto
-	 */
-	if(!trusted &&
-	   !(g_ascii_strncasecmp(uri, "http://", 7) == 0 ||
-		 g_ascii_strncasecmp(uri, "mailto:", 7) == 0 ||
-		 g_ascii_strncasecmp(uri, "https://", 8) == 0 ||
-		 g_ascii_strncasecmp(uri, "ftp://", 6) == 0)) {
-		gaim_debug_misc("gtknotify",
-						"Ignoring untrusted '%s' URI as it is not recognized as a secure URI.\n",
-						uri);
-	}
-	else {
-		int ret;
-		/* The URI is trusted */
-		if((ret = ShellExecute(NULL, "open", uri, NULL, NULL, SW_SHOWNORMAL)) <= 32)
-			gaim_debug_error("gtknotify", "Opening URI: '%s' ShellExecute failure: %d\n", uri, ret);
-	}
+	wgaim_notify_uri(uri);
 #endif /* !_WIN32 */
 
 	return NULL;
--- a/src/gtkutils.c	Mon Nov 22 21:56:46 2004 +0000
+++ b/src/gtkutils.c	Mon Nov 22 22:13:12 2004 +0000
@@ -64,7 +64,7 @@
 static gboolean
 url_clicked_idle_cb(gpointer data)
 {
-	gaim_notify_uri(NULL, data, FALSE);
+	gaim_notify_uri(NULL, data);
 	g_free(data);
 	return FALSE;
 }
--- a/src/notify.c	Mon Nov 22 21:56:46 2004 +0000
+++ b/src/notify.c	Mon Nov 22 22:13:12 2004 +0000
@@ -183,7 +183,7 @@
 }
 
 void *
-gaim_notify_uri(void *handle, const char *uri, gboolean trusted)
+gaim_notify_uri(void *handle, const char *uri)
 {
 	GaimNotifyUiOps *ops;
 
@@ -197,7 +197,7 @@
 		info            = g_new0(GaimNotifyInfo, 1);
 		info->type      = GAIM_NOTIFY_URI;
 		info->handle    = handle;
-		info->ui_handle = ops->notify_uri(uri, trusted);
+		info->ui_handle = ops->notify_uri(uri);
 
 		handles = g_list_append(handles, info);
 
--- a/src/notify.h	Mon Nov 22 21:56:46 2004 +0000
+++ b/src/notify.h	Mon Nov 22 22:13:12 2004 +0000
@@ -78,7 +78,7 @@
 							  const char *title, const char *primary,
 							  const char *secondary, const char *text,
 							  GCallback cb, void *user_data);
-	void *(*notify_uri)(const char *uri, gboolean trusted);
+	void *(*notify_uri)(const char *uri);
 
 	void (*close_notify)(GaimNotifyType type, void *ui_handle);
 
@@ -202,15 +202,14 @@
 /**
  * Opens a URI or somehow presents it to the user.
  *
- * @param handle  The plugin or connection handle.
- * @param uri     The URI to display or go to.
- * @param trusted The source of the URI is trusted.
+ * @param handle The plugin or connection handle.
+ * @param uri    The URI to display or go to.
  *
  * @return A UI-specific handle, if any. This may only be presented if
  *         the UI code displays a dialog instead of a webpage, or something
  *         similar.
  */
-void *gaim_notify_uri(void *handle, const char *uri, gboolean trusted);
+void *gaim_notify_uri(void *handle, const char *uri);
 
 /**
  * Closes a notification.
--- a/src/protocols/jabber/jabber.c	Mon Nov 22 21:56:46 2004 +0000
+++ b/src/protocols/jabber/jabber.c	Mon Nov 22 22:13:12 2004 +0000
@@ -571,7 +571,7 @@
 			if((url = xmlnode_get_child(x, "url"))) {
 				char *href;
 				if((href = xmlnode_get_data(url))) {
-					gaim_notify_uri(NULL, href, TRUE);
+					gaim_notify_uri(NULL, href);
 					g_free(href);
 					js->gc->wants_to_die = TRUE;
 					jabber_connection_schedule_close(js);
--- a/src/protocols/msn/notification.c	Mon Nov 22 21:56:46 2004 +0000
+++ b/src/protocols/msn/notification.c	Mon Nov 22 22:13:12 2004 +0000
@@ -829,27 +829,7 @@
 
 			unlink(session->passport_info.file);
 			g_free(session->passport_info.file);
-		}
-		else
-		{
-			/*
-			 * Renaming file with .html extension, so that the
-			 * win32 open_url will work.
-			 */
-			char *tmp;
-
-			if ((tmp =
-				 g_strdup_printf("%s.html", session->passport_info.file))
-				!= NULL)
-			{
-				if (rename(session->passport_info.file, tmp) == 0)
-				{
-					g_free(session->passport_info.file);
-					session->passport_info.file = tmp;
-				}
-				else
-					g_free(tmp);
-			}
+			session->passport_info.file = NULL;
 		}
 	}
 }
--- a/src/protocols/oscar/oscar.c	Mon Nov 22 21:56:46 2004 +0000
+++ b/src/protocols/oscar/oscar.c	Mon Nov 22 22:13:12 2004 +0000
@@ -7194,7 +7194,7 @@
 static void oscar_show_set_info_icqurl(GaimPluginAction *action)
 {
 	GaimConnection *gc = (GaimConnection *) action->context;
-	gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php", TRUE);
+	gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php");
 }
 
 static void oscar_change_pass(GaimPluginAction *action)
@@ -7208,14 +7208,14 @@
 	GaimConnection *gc = (GaimConnection *) action->context;
 	OscarData *od = gc->proto_data;
 	gchar *substituted = gaim_strreplace(od->sess->authinfo->chpassurl, "%s", gaim_account_get_username(gaim_connection_get_account(gc)));
-	gaim_notify_uri(gc, substituted, TRUE);
+	gaim_notify_uri(gc, substituted);
 	g_free(substituted);
 }
 
 static void oscar_show_imforwardingurl(GaimPluginAction *action)
 {
 	GaimConnection *gc = (GaimConnection *) action->context;
-	gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1", TRUE);
+	gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1");
 }
 
 static void oscar_set_icon(GaimConnection *gc, const char *iconfile)
--- a/src/protocols/trepia/trepia.c	Mon Nov 22 21:56:46 2004 +0000
+++ b/src/protocols/trepia/trepia.c	Mon Nov 22 22:13:12 2004 +0000
@@ -459,7 +459,7 @@
 	value = trepia_profile_get_homepage(profile);
 
 	if (value != NULL)
-		gaim_notify_uri(gc, value, FALSE);
+		gaim_notify_uri(gc, value);
 }
 
 static GList *
--- a/src/protocols/yahoo/yahoo.c	Mon Nov 22 21:56:46 2004 +0000
+++ b/src/protocols/yahoo/yahoo.c	Mon Nov 22 22:13:12 2004 +0000
@@ -2713,7 +2713,7 @@
 		t++;
 	*t = 0;
 	g_snprintf(url, sizeof url, "http://games.yahoo.com/games/%s", game2);
-	gaim_notify_uri(gc, url, TRUE);
+	gaim_notify_uri(gc, url);
 	g_free(game2);
 }
 
--- a/src/win32/win32dep.c	Mon Nov 22 21:56:46 2004 +0000
+++ b/src/win32/win32dep.c	Mon Nov 22 22:13:12 2004 +0000
@@ -507,6 +507,24 @@
 	RestoreWndFromTray(GDK_WINDOW_HWND(window->window));
 }
 
+void wgaim_notify_uri(const char *uri) {
+	SHELLEXECUTEINFO sinfo;
+
+	memset(&sinfo, 0, sizeof(sinfo));
+    sinfo.cbSize = sizeof(sinfo);
+    sinfo.fMask = SEE_MASK_CLASSNAME;
+    sinfo.lpVerb = "open";
+    sinfo.lpFile = uri; 
+    sinfo.nShow = SW_SHOWNORMAL; 
+    sinfo.lpClass = "http";
+
+	/* We'll allow whatever URI schemes are supported by the
+	   default http browser.
+	*/
+	if(!ShellExecuteEx(&sinfo))
+		gaim_debug_error("wgaim", "Error opening URI: %s error: %d\n", uri, (int)sinfo.hInstApp);
+}
+
 void wgaim_init(HINSTANCE hint) {
 	WORD wVersionRequested;
 	WSADATA wsaData;
--- a/src/win32/win32dep.h	Mon Nov 22 21:56:46 2004 +0000
+++ b/src/win32/win32dep.h	Mon Nov 22 22:13:12 2004 +0000
@@ -56,6 +56,8 @@
 /* Docklet */
 extern void      wgaim_systray_minimize( GtkWidget* );
 extern void      wgaim_systray_maximize( GtkWidget* );
+/* Misc */
+extern void      wgaim_notify_uri(const char *uri);
 /* init / cleanup */
 extern void      wgaim_init(HINSTANCE);
 extern void      wgaim_cleanup(void);