[vlc-commits] input: Reintroduce subtitle extension check

Hugo Beauzée-Luyssen git at videolan.org
Wed Oct 4 11:24:38 CEST 2017


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Tue Oct  3 18:07:33 2017 +0200| [31e424004db5da4f8b6e247b0d27ec03f7dc7bce] | committer: Hugo Beauzée-Luyssen

input: Reintroduce subtitle extension check

Fix #18882

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

 include/vlc_input.h                     | 10 +++++++---
 lib/media_player.c                      |  2 +-
 lib/video.c                             |  2 +-
 modules/gui/macosx/VLCCoreInteraction.m |  2 +-
 modules/gui/macosx/VLCPlaylist.m        |  2 +-
 modules/gui/qt/dialogs_provider.cpp     |  2 +-
 modules/gui/qt/main_interface.cpp       |  2 +-
 modules/gui/skins2/src/top_window.cpp   |  2 +-
 modules/lua/libs/input.c                |  4 ++--
 src/input/control.c                     |  4 ++++
 10 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/include/vlc_input.h b/include/vlc_input.h
index d225f1e3f2..360539964c 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -460,7 +460,9 @@ enum input_query_e
     INPUT_GET_ATTACHMENT,  /* arg1=input_attachment_t**, arg2=char*  res=can fail */
 
     /* On the fly input slave */
-    INPUT_ADD_SLAVE,       /* arg1= enum slave_type, arg2= const char *, arg3= bool, arg4= bool */
+    INPUT_ADD_SLAVE,       /* arg1= enum slave_type, arg2= const char *,
+                            * arg3= bool forced, arg4= bool notify,
+                            * arg5= bool check_extension */
     INPUT_ADD_SUBTITLE,    /* arg1= const char *, arg2=bool b_check_extension */
 
     /* On the fly record while playing */
@@ -576,9 +578,11 @@ static inline vout_thread_t *input_GetVout( input_thread_t *p_input )
 }
 
 static inline int input_AddSlave( input_thread_t *p_input, enum slave_type type,
-                                  const char *psz_uri, bool b_forced, bool b_notify )
+                                  const char *psz_uri, bool b_forced,
+                                  bool b_notify, bool b_check_ext )
 {
-    return input_Control( p_input, INPUT_ADD_SLAVE, type, psz_uri, b_forced, b_notify );
+    return input_Control( p_input, INPUT_ADD_SLAVE, type, psz_uri, b_forced,
+                          b_notify, b_check_ext );
 }
 
 /**
diff --git a/lib/media_player.c b/lib/media_player.c
index 8ccf3179cb..7247cdea85 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -1936,7 +1936,7 @@ int libvlc_media_player_add_slave( libvlc_media_player_t *p_mi,
     else
     {
         int i_ret = input_AddSlave( p_input_thread, (enum slave_type) i_type,
-                                    psz_uri, b_select, false );
+                                    psz_uri, b_select, false, false );
         vlc_object_release( p_input_thread );
 
         return i_ret == VLC_SUCCESS ? 0 : -1;
diff --git a/lib/video.c b/lib/video.c
index c41c6e35ff..acbba3a30f 100644
--- a/lib/video.c
+++ b/lib/video.c
@@ -407,7 +407,7 @@ int libvlc_video_set_subtitle_file( libvlc_media_player_t *p_mi,
         if( psz_mrl )
         {
             if( !input_AddSlave( p_input_thread, SLAVE_TYPE_SPU, psz_mrl,
-                                 true, false ) )
+                                 true, false, false ) )
                 b_ret = true;
             free( psz_mrl );
         }
diff --git a/modules/gui/macosx/VLCCoreInteraction.m b/modules/gui/macosx/VLCCoreInteraction.m
index 970895df4c..2aff35a737 100644
--- a/modules/gui/macosx/VLCCoreInteraction.m
+++ b/modules/gui/macosx/VLCCoreInteraction.m
@@ -613,7 +613,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
             continue;
         msg_Dbg(getIntf(), "loading subs from %s", mrl);
 
-        int i_result = input_AddSlave(p_input, SLAVE_TYPE_SPU, mrl, true, true);
+        int i_result = input_AddSlave(p_input, SLAVE_TYPE_SPU, mrl, true, true, true);
         if (i_result != VLC_SUCCESS)
             msg_Warn(getIntf(), "unable to load subtitles from '%s'", mrl);
         free(mrl);
diff --git a/modules/gui/macosx/VLCPlaylist.m b/modules/gui/macosx/VLCPlaylist.m
index bfb0d0f0a5..5e5f6e4a07 100644
--- a/modules/gui/macosx/VLCPlaylist.m
+++ b/modules/gui/macosx/VLCPlaylist.m
@@ -608,7 +608,7 @@
     if (isSubtitle && array.count == 1 && p_input) {
         int i_result = input_AddSlave(p_input, SLAVE_TYPE_SPU,
                     [[[array firstObject] objectForKey:@"ITEM_URL"] UTF8String],
-                    true, true);
+                    true, true, true);
         if (i_result == VLC_SUCCESS) {
             vlc_object_release(p_input);
             return;
diff --git a/modules/gui/qt/dialogs_provider.cpp b/modules/gui/qt/dialogs_provider.cpp
index ec645ab62a..495cd54972 100644
--- a/modules/gui/qt/dialogs_provider.cpp
+++ b/modules/gui/qt/dialogs_provider.cpp
@@ -806,7 +806,7 @@ void DialogsProvider::loadSubtitlesFile()
     free( path2 );
     foreach( const QString &qsUrl, qsl )
     {
-        if( input_AddSlave( p_input, SLAVE_TYPE_SPU, qtu( qsUrl ), true, true ) )
+        if( input_AddSlave( p_input, SLAVE_TYPE_SPU, qtu( qsUrl ), true, true, true ) )
             msg_Warn( p_intf, "unable to load subtitles from '%s'",
                       qtu( qsUrl ) );
     }
diff --git a/modules/gui/qt/main_interface.cpp b/modules/gui/qt/main_interface.cpp
index 3a52373ad0..b586900f02 100644
--- a/modules/gui/qt/main_interface.cpp
+++ b/modules/gui/qt/main_interface.cpp
@@ -1453,7 +1453,7 @@ void MainInterface::dropEventPlay( QDropEvent *event, bool b_play, bool b_playli
     if( mimeData->urls().count() == 1 && THEMIM->getIM()->hasInput() )
     {
         if( !input_AddSlave( THEMIM->getInput(), SLAVE_TYPE_SPU,
-                 qtu( mimeData->urls()[0].toString() ), true, true ) )
+                 qtu( mimeData->urls()[0].toString() ), true, true, true ) )
         {
             event->accept();
             return;
diff --git a/modules/gui/skins2/src/top_window.cpp b/modules/gui/skins2/src/top_window.cpp
index 403eda6af5..260872e420 100644
--- a/modules/gui/skins2/src/top_window.cpp
+++ b/modules/gui/skins2/src/top_window.cpp
@@ -265,7 +265,7 @@ void TopWindow::processEvent( EvtDragDrop &rEvtDragDrop )
         {
             std::list<std::string>::const_iterator it = files.begin();
             is_subtitle = !input_AddSlave( pInput, SLAVE_TYPE_SPU,
-                                           it->c_str(), true, true );
+                                           it->c_str(), true, true, true );
         }
         if( !is_subtitle )
         {
diff --git a/modules/lua/libs/input.c b/modules/lua/libs/input.c
index f98818c9cc..229f52b6e5 100644
--- a/modules/lua/libs/input.c
+++ b/modules/lua/libs/input.c
@@ -239,13 +239,13 @@ static int vlclua_input_add_subtitle( lua_State *L, bool b_path )
         b_autoselect = lua_toboolean( L, 2 );
     const char *psz_sub = luaL_checkstring( L, 1 );
     if( !b_path )
-        input_AddSlave( p_input, SLAVE_TYPE_SPU, psz_sub, b_autoselect, true );
+        input_AddSlave( p_input, SLAVE_TYPE_SPU, psz_sub, b_autoselect, true, false );
     else
     {
         char* psz_mrl = vlc_path2uri( psz_sub, NULL );
         if ( psz_mrl )
         {
-            input_AddSlave( p_input, SLAVE_TYPE_SPU, psz_mrl, b_autoselect, true );
+            input_AddSlave( p_input, SLAVE_TYPE_SPU, psz_mrl, b_autoselect, true, false );
             free( psz_mrl );
         }
     }
diff --git a/src/input/control.c b/src/input/control.c
index df3ab765a3..29f516208c 100644
--- a/src/input/control.c
+++ b/src/input/control.c
@@ -412,9 +412,13 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
             psz = va_arg( args, char * );
             b_bool = va_arg( args, int );
             bool b_notify = va_arg( args, int );
+            bool b_check_ext = va_arg( args, int );
 
             if( !psz || ( type != SLAVE_TYPE_SPU && type != SLAVE_TYPE_AUDIO ) )
                 return VLC_EGENERIC;
+            if( b_check_ext && type == SLAVE_TYPE_SPU &&
+                !subtitles_Filter( psz ) )
+                return VLC_EGENERIC;
 
             input_item_slave_t *p_slave =
                 input_item_slave_New( psz, type, SLAVE_PRIORITY_USER );



More information about the vlc-commits mailing list