From bbdaa0b64a0626282d1dca2051c233969f00e1d7 Mon Sep 17 00:00:00 2001
From: Alaric Senat <dev.asenat@posteo.net>
Date: Fri, 2 Apr 2021 16:30:07 +0200
Subject: [PATCH] input: add url parsing of `input-slave` option

As shown in #25549, we need to extract the path from the url in order to
check the file extension without the eventual HTTP's options noise.

Fixes: #25549
Signed-off-by: Thomas Guillem <thomas@gllm.fr>
---
 src/input/input.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/input/input.c b/src/input/input.c
index 286dfe3fd721..e52fdd9d2ff2 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -984,8 +984,18 @@ static void GetVarSlaves( input_thread_t *p_input,
         if( uri == NULL )
             continue;
 
+        vlc_url_t parsed_uri;
+        if ( vlc_UrlParse( &parsed_uri, uri ) != VLC_SUCCESS )
+        {
+            msg_Err( p_input,
+                    "Invalid url passed to the \"input-slave\" option" );
+            vlc_UrlClean( &parsed_uri );
+            free( uri );
+            continue;
+        }
+
         enum slave_type i_type;
-        if ( !input_item_slave_GetType(uri, &i_type) )
+        if ( !input_item_slave_GetType( parsed_uri.psz_path, &i_type ) )
         {
             msg_Warn( p_input,
                      "Can't deduce slave type of `%s\" with file extension.",
@@ -995,6 +1005,7 @@ static void GetVarSlaves( input_thread_t *p_input,
         input_item_slave_t *p_slave =
             input_item_slave_New( uri, i_type, SLAVE_PRIORITY_USER );
 
+        vlc_UrlClean( &parsed_uri );
         free( uri );
 
         if( unlikely( p_slave == NULL ) )
-- 
GitLab