[vlc] audioscrobbler parseURL can't handle URLs without explicit ports

Clint Adams schizo at debian.org
Mon Apr 27 01:30:24 CEST 2009


I think something like this (untested) needs to be used with
the patch in ticket #2683, to cope with situations where the
URL returned looks like
http://turtle.dev.libre.fm/submissions/1.2/
(no :80)

I seem to be unable to do anything in Trac.

diff --git a/modules/misc/audioscrobbler.c b/modules/misc/audioscrobbler.c
index d9e7f8c..abf8a85 100644
--- a/modules/misc/audioscrobbler.c
+++ b/modules/misc/audioscrobbler.c
@@ -654,17 +654,22 @@ static int ParseURL( char *psz_url, char **psz_host, char **psz_file,
 {
     int i_pos;
     int i_len = strlen( psz_url );
+    int no_port = 0;
     FREENULL( *psz_host );
     FREENULL( *psz_file );
 
     i_pos = strcspn( psz_url, ":" );
-    if( i_pos == i_len )
-        return VLC_EGENERIC;
+    if( i_pos == i_len ) {
+        i_port = 80;
+        i_pos = strcspn( psz_url, "/" );
+	no_port = 1;
+    }
 
     *psz_host = strndup( psz_url, i_pos );
     if( !*psz_host )
         return VLC_ENOMEM;
 
+    if( no_port == 0) {
     i_pos++; /* skip the ':' */
     *i_port = atoi( psz_url + i_pos );
     if( *i_port <= 0 )
@@ -674,6 +679,7 @@ static int ParseURL( char *psz_url, char **psz_host, char **psz_file,
     }
 
     i_pos = strcspn( psz_url, "/" );
+    }
 
     if( i_pos == i_len )
         return VLC_EGENERIC;



More information about the vlc mailing list