Commit d7a88fe0 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

url: remove vlc_UrlParse() option parameter

That parameter assumed that the query was part of the path. However it
is not, which leads to invalid host name, and eventually failure when
the path is missing. In practice, passing any value other than '?' as
separator would not work properly.

Remaining vlc_UrlParse() call sites without the option separator do not
support query at the protocol level anyway, so they are unaffected by the
change.
Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent 0e4ff269
......@@ -50,6 +50,6 @@ VLC_API char * decode_URI( char *psz );
VLC_API char * encode_URI_component( const char *psz ) VLC_MALLOC;
VLC_API char * make_path( const char *url ) VLC_MALLOC;
VLC_API void vlc_UrlParse (vlc_url_t *, const char *, unsigned char);
VLC_API void vlc_UrlParse (vlc_url_t *, const char *);
VLC_API void vlc_UrlClean (vlc_url_t *);
#endif
......@@ -164,7 +164,7 @@ static int Open( vlc_object_t *p_this )
if( p_sys->p_session == NULL )
goto error;
vlc_UrlParse( &p_sys->url, p_access->psz_location, 0 );
vlc_UrlParse( &p_sys->url, p_access->psz_location );
get_credentials( p_access );
if( get_address( p_access ) != VLC_SUCCESS )
goto error;
......
......@@ -578,7 +578,7 @@ static int parseURL( vlc_url_t *url, const char *path, enum tls_mode_e mode )
while( *path == '/' )
path++;
vlc_UrlParse( url, path, 0 );
vlc_UrlParse( url, path );
if( url->psz_host == NULL || *url->psz_host == '\0' )
return VLC_EGENERIC;
......
......@@ -136,7 +136,7 @@ static int Open( vlc_object_t *p_this )
char *psz_escaped_path;
char *psz_path_begin;
vlc_UrlParse( &url, psz_unescaped, 0 );
vlc_UrlParse( &url, psz_unescaped );
psz_escaped_path = gnome_vfs_escape_path_string( url.psz_path );
if( psz_escaped_path )
......
......@@ -287,7 +287,7 @@ static int OpenRedirected( vlc_object_t *p_this, const char *psz_access,
p = psz = strdup( p_access->psz_location );
while( (p = strchr( p, ' ' )) != NULL )
*p = '+';
vlc_UrlParse( &p_sys->url, psz, '?' );
vlc_UrlParse( &p_sys->url, psz );
free( psz );
if( p_sys->url.psz_host == NULL || *p_sys->url.psz_host == '\0' )
......@@ -372,7 +372,7 @@ static int OpenRedirected( vlc_object_t *p_this, const char *psz_access,
if( psz != NULL )
{
p_sys->b_proxy = true;
vlc_UrlParse( &p_sys->proxy, psz, '?' );
vlc_UrlParse( &p_sys->proxy, psz );
free( psz );
psz = var_InheritString( p_access, "http-proxy-pwd" );
......
......@@ -314,7 +314,7 @@ static int Open ( vlc_object_t *p_this )
vlc_mutex_init(&p_sys->timeout_mutex);
/* parse URL for rtsp://[user:[passwd]@]serverip:port/options */
vlc_UrlParse( &p_sys->url, p_sys->psz_path, '?' );
vlc_UrlParse( &p_sys->url, p_sys->psz_path );
if( ( p_sys->scheduler = BasicTaskScheduler::createNew() ) == NULL )
{
......
......@@ -105,7 +105,7 @@ int MMSHOpen( access_t *p_access )
if( psz_proxy )
{
p_sys->b_proxy = true;
vlc_UrlParse( &p_sys->proxy, psz_proxy, '?' );
vlc_UrlParse( &p_sys->proxy, psz_proxy );
free( psz_proxy );
}
else
......@@ -114,7 +114,7 @@ int MMSHOpen( access_t *p_access )
if( http_proxy )
{
p_sys->b_proxy = true;
vlc_UrlParse( &p_sys->proxy, http_proxy, '?' );
vlc_UrlParse( &p_sys->proxy, http_proxy );
}
}
......@@ -136,7 +136,7 @@ int MMSHOpen( access_t *p_access )
}
/* open a tcp connection */
vlc_UrlParse( &p_sys->url, p_access->psz_location, '?' );
vlc_UrlParse( &p_sys->url, p_access->psz_location );
if( ( p_sys->url.psz_host == NULL ) ||
( *p_sys->url.psz_host == '\0' ) )
{
......
......@@ -105,7 +105,7 @@ int MMSTUOpen( access_t *p_access )
vlc_mutex_init( &p_sys->lock_netwrite );
/* *** Parse URL and get server addr/port and path *** */
vlc_UrlParse( &p_sys->url, p_access->psz_location, '?' );
vlc_UrlParse( &p_sys->url, p_access->psz_location );
if( p_sys->url.psz_host == NULL || *p_sys->url.psz_host == '\0' )
{
msg_Err( p_access, "invalid server name" );
......
......@@ -458,7 +458,7 @@ static int Open( vlc_object_t *p_this )
/* Parse uri params for pre-connect */
vlc_url_t url;
vlc_UrlParse( &url, p_demux->psz_location, 0 );
vlc_UrlParse( &url, p_demux->psz_location );
if ( !EMPTY_STR(url.psz_host) )
p_sys->psz_hostname = strdup( url.psz_host );
......
......@@ -130,7 +130,7 @@ static int Open( vlc_object_t* p_this )
p_sys->i_socket = -1;
/* Parse the URL */
vlc_UrlParse( &url, p_access->psz_location, 0 );
vlc_UrlParse( &url, p_access->psz_location );
/* Check for some parameters */
if( EMPTY_STR( url.psz_host ) )
......
......@@ -442,7 +442,7 @@ static int Open( vlc_object_t *p_this )
/* Parse uri params */
vlc_url_t url;
vlc_UrlParse( &url, p_demux->psz_location, 0 );
vlc_UrlParse( &url, p_demux->psz_location );
if ( !EMPTY_STR(url.psz_host) )
p_sys->p_client->serverHost = strdup( url.psz_host );
......
......@@ -184,7 +184,7 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC;
}
vlc_UrlParse( &url , p_access->psz_path, 0 );
vlc_UrlParse( &url , p_access->psz_path );
if( url.i_port <= 0 )
url.i_port = 8000;
......
......@@ -301,7 +301,7 @@ static int Activate( vlc_object_t *p_this )
{
vlc_url_t url;
vlc_UrlParse( &url, psz_host, 0 );
vlc_UrlParse( &url, psz_host );
msg_Dbg( p_intf, "base: %s, port: %d", url.psz_host, url.i_port );
......
......@@ -54,7 +54,7 @@ Chunk::Chunk (const std::string& url) :
throw VLC_EGENERIC;
vlc_url_t url_components;
vlc_UrlParse(&url_components, url.c_str(), '?');
vlc_UrlParse(&url_components, url.c_str());
if(url_components.psz_path)
path = url_components.psz_path;
......
......@@ -90,7 +90,7 @@ static char *MakeConfig( intf_thread_t *p_intf, const char *name )
else
{
vlc_url_t url;
vlc_UrlParse( &url, psz_host, 0 );
vlc_UrlParse( &url, psz_host );
unsigned i_port = var_InheritInteger( p_intf, "telnet-port" );
if ( url.i_port != 0 )
{
......
......@@ -166,10 +166,9 @@ static void vlclua_fd_unmap_safe( lua_State *L, unsigned idx )
static int vlclua_url_parse( lua_State *L )
{
const char *psz_url = luaL_checkstring( L, 1 );
const char *psz_option = luaL_optstring( L, 2, NULL );
vlc_url_t url;
vlc_UrlParse( &url, psz_url, psz_option?*psz_option:0 );
vlc_UrlParse( &url, psz_url );
lua_newtable( L );
lua_pushstring( L, url.psz_protocol );
......
......@@ -644,7 +644,7 @@ static int Handshake(intf_thread_t *p_this)
goto oom;
/* parse the submission url */
vlc_UrlParse(&p_sys->p_submit_url, psz_url, 0);
vlc_UrlParse(&p_sys->p_submit_url, psz_url);
free(psz_url);
return VLC_SUCCESS;
......
......@@ -256,7 +256,7 @@ static int Open( vlc_object_t *p_this )
vlc_url_t url;
psz_url = var_InheritString( p_vod, "rtsp-host" );
vlc_UrlParse( &url, psz_url, 0 );
vlc_UrlParse( &url, psz_url );
free( psz_url );
p_vod->p_sys = p_sys = malloc( sizeof( vod_sys_t ) );
......
......@@ -543,7 +543,7 @@ MediaServer::~MediaServer()
input_item_t* MediaServer::newItem(const char *objectID, const char *title )
{
vlc_url_t url;
vlc_UrlParse( &url, url_.c_str(), '?' );
vlc_UrlParse( &url, url_.c_str() );
char* psz_url;
if (asprintf( &psz_url, "upnp://%s://%s:%u%s?ObjectID=%s", url.psz_protocol,
......@@ -673,7 +673,7 @@ void MediaServer::fetchContents()
{
const char* objectID = "";
vlc_url_t url;
vlc_UrlParse( &url, access_->psz_location, '?');
vlc_UrlParse( &url, access_->psz_location );
if ( url.psz_option && !strncmp( url.psz_option, "ObjectID=", strlen( "ObjectID=" ) ) )
{
......
......@@ -699,7 +699,7 @@ static void SDPHandleUrl( sout_stream_t *p_stream, const char *psz_url )
sout_stream_sys_t *p_sys = p_stream->p_sys;
vlc_url_t url;
vlc_UrlParse( &url, psz_url, 0 );
vlc_UrlParse( &url, psz_url );
if( url.psz_protocol && !strcasecmp( url.psz_protocol, "http" ) )
{
if( p_sys->p_httpd_file )
......
......@@ -127,7 +127,7 @@ int OpenVoD( vlc_object_t *p_this )
else
{
vlc_url_t url;
vlc_UrlParse( &url, psz_url, 0 );
vlc_UrlParse( &url, psz_url );
free( psz_url );
if( url.psz_path == NULL )
......
......@@ -163,7 +163,7 @@ Net
/!\ NB: this namespace is ONLY usable for interfaces and extensions.
---
----------------------------------------------------------------
net.url_parse( url, [option delimiter] ): Parse URL. Returns a table with
net.url_parse( url ): Parse URL. Returns a table with
fields "protocol", "username", "password", "host", "port", path" and
"option".
net.listen_tcp( host, port ): Listen to TCP connections. This returns an
......
......@@ -339,7 +339,7 @@ void input_item_SetURI( input_item_t *p_i, const char *psz_uri )
int r;
vlc_url_t url;
vlc_UrlParse( &url, psz_uri, 0 );
vlc_UrlParse( &url, psz_uri );
if( url.psz_protocol )
{
if( url.i_port > 0 )
......
......@@ -916,7 +916,7 @@ static httpd_host_t *httpd_HostCreate(vlc_object_t *p_this,
unsigned port = var_InheritInteger(p_this, portvar);
vlc_url_t url;
vlc_UrlParse(&url, hostname, 0);
vlc_UrlParse(&url, hostname);
free(hostname);
if (url.i_port != 0) {
msg_Err(p_this, "Ignoring port %d (using %d)", url.i_port, port);
......
......@@ -99,7 +99,7 @@ static void test_url_parse(const char* in, const char* protocol, const char* use
assert(b != NULL && !strcmp((a), (b)))
vlc_url_t url;
vlc_UrlParse( &url, in, '?' );
vlc_UrlParse( &url, in );
CHECK( url.psz_protocol, protocol );
CHECK( url.psz_username, user );
CHECK( url.psz_password, pass );
......
......@@ -350,13 +350,11 @@ static char *vlc_idna_to_ascii (const char *);
* Splits an URL into parts.
* \param url structure of URL parts [OUT]
* \param str nul-terminated URL string to split
* \param opt if non-zero, character separating paths from options,
* normally the question mark
* \note Use vlc_UrlClean() to free associated resources
* \bug Errors cannot be detected.
* \return nothing
*/
void vlc_UrlParse (vlc_url_t *restrict url, const char *str, unsigned char opt)
void vlc_UrlParse (vlc_url_t *restrict url, const char *str)
{
url->psz_protocol = NULL;
url->psz_username = NULL;
......@@ -396,14 +394,11 @@ void vlc_UrlParse (vlc_url_t *restrict url, const char *str, unsigned char opt)
}
/* Query parameters */
if (opt != '\0')
char *query = strchr (cur, '?');
if (query != NULL)
{
char *query = strchr (cur, opt);
if (query != NULL)
{
*(query++) = '\0';
url->psz_option = query;
}
*(query++) = '\0';
url->psz_option = query;
}
/* Path */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment