changeset 15287:96abd13cc0b3

[gaim-migrate @ 18076] Christian Grothoff pointed out that our UPnP code doesn't properly handle relative URLs which are an absolute path -- fixed. committer: Tailor Script <tailor@pidgin.im>
author Ethan Blanton <elb@pidgin.im>
date Fri, 05 Jan 2007 02:44:31 +0000
parents 21509d8e4e70
children 8b72da628537
files libgaim/upnp.c
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libgaim/upnp.c	Thu Jan 04 23:55:17 2007 +0000
+++ b/libgaim/upnp.c	Fri Jan 05 02:44:31 2007 +0000
@@ -341,7 +341,18 @@
 	tmp = xmlnode_get_data(controlURLNode);
 	if(baseURL && !gaim_str_has_prefix(tmp, "http://") &&
 	   !gaim_str_has_prefix(tmp, "HTTP://")) {
-		controlURL = g_strdup_printf("%s%s", baseURL, tmp);
+		/* Handle absolute paths in a relative URL.  This probably
+		 * belongs in util.c. */
+		if (tmp[0] == '/') {
+			size_t length;
+			const char *path, *start = strstr(baseURL, "://");
+			start = start ? start + 3 : baseURL;
+			path = strchr(start, '/');
+			length = path ? path - baseURL : strlen(baseURL);
+			controlURL = g_strdup_printf("%.*s%s", length, baseURL, tmp);
+		} else {
+			controlURL = g_strdup_printf("%s%s", baseURL, tmp);
+		}
 		g_free(tmp);
 	}else{
 		controlURL = tmp;