[vlc-commits] upnp: Don't drop potential options from the control URL

Hugo Beauzée-Luyssen git at videolan.org
Wed May 25 19:06:21 CEST 2016


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Wed May 25 18:54:06 2016 +0200| [ac99cee9f34fa17e0595d8b31a2dd1ff723c0719] | committer: Hugo Beauzée-Luyssen

upnp: Don't drop potential options from the control URL

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ac99cee9f34fa17e0595d8b31a2dd1ff723c0719
---

 modules/services_discovery/upnp.cpp |   23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/modules/services_discovery/upnp.cpp b/modules/services_discovery/upnp.cpp
index 1fa2aa4..6429907 100644
--- a/modules/services_discovery/upnp.cpp
+++ b/modules/services_discovery/upnp.cpp
@@ -324,7 +324,9 @@ bool MediaServerList::addServer( MediaServerDesc* desc )
                                                 ITEM_NET );
     } else {
         char* psz_mrl;
-        if( asprintf(&psz_mrl, "upnp://%s?ObjectID=0", desc->location.c_str() ) < 0 )
+        // We might already have some options specified in the location.
+        char opt_delim = desc->location.find( '?' ) == 0 ? '?' : '&';
+        if( asprintf( &psz_mrl, "upnp://%s%cObjectID=0", desc->location.c_str(), opt_delim ) < 0 )
             return false;
 
         p_input_item = input_item_NewDirectory( psz_mrl,
@@ -760,20 +762,19 @@ MediaServer::MediaServer( access_t *p_access, input_item_node_t *node )
     , node_( node )
 
 {
-    vlc_url_t url;
-    vlc_UrlParse( &url, p_access->psz_location );
-    if ( asprintf( &psz_root_, "%s://%s:%u%s", url.psz_protocol,
-                  url.psz_host, url.i_port ? url.i_port : 80, url.psz_path ) < 0 )
-        psz_root_ = NULL;
-
-    if ( url.psz_option && !strncmp( url.psz_option, "ObjectID=", strlen( "ObjectID=" ) ) )
-        psz_objectId_ = strdup( &url.psz_option[strlen( "ObjectID=" )] );
-    vlc_UrlClean( &url );
+    psz_root_ = strdup( p_access->psz_location );
+    char* psz_objectid = strstr( psz_root_, "ObjectID=" );
+    if ( psz_objectid != NULL )
+    {
+        // Remove this parameter from the URL, since it might cause some servers to fail
+        // Keep in mind that we added a '&' or a '?' to the URL, so remove it as well
+        *( psz_objectid - 1) = 0;
+        psz_objectId_ = &psz_objectid[strlen( "ObjectID=" )];
+    }
 }
 
 MediaServer::~MediaServer()
 {
-    free( psz_objectId_ );
     free( psz_root_ );
 }
 



More information about the vlc-commits mailing list