[vlc-commits] podcast: accept "text/xml" mime type
Thomas Guillem
git at videolan.org
Fri Nov 3 12:00:36 CET 2017
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Oct 30 10:23:23 2017 +0100| [368ea18228184a3a429cb83711a93ef07a94d8ab] | committer: Thomas Guillem
podcast: accept "text/xml" mime type
Check for the "rss" node from the Open function in that case.
Fixes #18995
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=368ea18228184a3a429cb83711a93ef07a94d8ab
---
modules/demux/playlist/podcast.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/modules/demux/playlist/podcast.c b/modules/demux/playlist/podcast.c
index 8c47d5ab6f..8c52f7e08d 100644
--- a/modules/demux/playlist/podcast.c
+++ b/modules/demux/playlist/podcast.c
@@ -49,7 +49,44 @@ int Import_podcast( vlc_object_t *p_this )
stream_t *p_demux = (stream_t *)p_this;
CHECK_FILE(p_demux);
- if( !stream_IsMimeType( p_demux->p_source, "application/rss+xml" ) )
+ if( stream_IsMimeType( p_demux->p_source, "text/xml" ) )
+ {
+ /* XML: check if the root node is "rss". Use a specific peeked
+ * probestream in order to not modify the source state while probing.
+ * */
+ uint8_t *p_peek;
+ ssize_t i_peek = vlc_stream_Peek( p_demux->p_source,
+ (const uint8_t **) &p_peek, 2048 );
+ if( unlikely( i_peek <= 0 ) )
+ return VLC_EGENERIC;
+
+ stream_t *p_probestream =
+ vlc_stream_MemoryNew( p_demux->p_source, p_peek, i_peek, true );
+ if( unlikely( !p_probestream ) )
+ return VLC_EGENERIC;
+
+ xml_reader_t *p_xml_reader = xml_ReaderCreate( p_demux, p_probestream );
+ if( !p_xml_reader )
+ {
+ vlc_stream_Delete( p_probestream );
+ return VLC_EGENERIC;
+ }
+
+ const char *node;
+ int ret;
+ if( ( ret = xml_ReaderNextNode( p_xml_reader, &node ) ) != XML_READER_STARTELEM
+ || strcmp( node, "rss" ) )
+ {
+ vlc_stream_Delete( p_probestream );
+ xml_ReaderDelete( p_xml_reader );
+ return VLC_EGENERIC;
+ }
+
+ xml_ReaderDelete( p_xml_reader );
+ vlc_stream_Delete( p_probestream );
+ /* SUCCESS: this text/xml is a rss file */
+ }
+ else if( !stream_IsMimeType( p_demux->p_source, "application/rss+xml" ) )
return VLC_EGENERIC;
p_demux->pf_readdir = ReadDir;
More information about the vlc-commits
mailing list