Commit af40daab authored by Gildas Bazin's avatar Gildas Bazin

* modules/misc/xml/*, include/vlc_xml.h: new xml_ReaderUseDTD() api to...

* modules/misc/xml/*, include/vlc_xml.h: new xml_ReaderUseDTD() api to enable/disable DTD validation.
parent c849b85a
......@@ -63,6 +63,8 @@ struct xml_reader_t
char * (*pf_name) ( xml_reader_t * );
char * (*pf_value) ( xml_reader_t * );
int (*pf_next_attr) ( xml_reader_t * );
int (*pf_use_dtd) ( xml_reader_t *, vlc_bool_t );
};
#define xml_ReaderRead( a ) a->pf_read( a )
......@@ -70,6 +72,7 @@ struct xml_reader_t
#define xml_ReaderName( a ) a->pf_name( a )
#define xml_ReaderValue( a ) a->pf_value( a )
#define xml_ReaderNextAttr( a ) a->pf_next_attr( a )
#define xml_ReaderUseDTD( a, b ) a->pf_use_dtd( a, b )
#define XML_READER_NONE 0
#define XML_READER_STARTELEM 1
......
......@@ -63,6 +63,9 @@ XMLParser::XMLParser( intf_thread_t *pIntf, const string &rFileName ):
rFileName.c_str() );
return;
}
xml_ReaderUseDTD( m_pReader, VLC_TRUE );
}
......
......@@ -59,6 +59,8 @@ static char *ReaderName( xml_reader_t * );
static char *ReaderValue( xml_reader_t * );
static int ReaderNextAttr( xml_reader_t * );
static int ReaderUseDTD ( xml_reader_t *, vlc_bool_t );
static void CatalogLoad( xml_t *, const char * );
static void CatalogAdd( xml_t *, const char *, const char *, const char * );
static int StreamRead( void *p_context, char *p_buffer, int i_buffer );
......@@ -136,10 +138,6 @@ static xml_reader_t *ReaderCreate( xml_t *p_xml, stream_t *p_stream )
p_reader->p_sys->p_reader = p_libxml_reader;
p_reader->p_xml = p_xml;
/* Activate DTD validation */
xmlTextReaderSetParserProp( p_libxml_reader, XML_PARSER_DEFAULTATTRS, 1 );
xmlTextReaderSetParserProp( p_libxml_reader, XML_PARSER_VALIDATE, 1 );
/* Set the error handler */
xmlTextReaderSetErrorHandler( p_libxml_reader,
ReaderErrorHandler, p_reader );
......@@ -150,6 +148,7 @@ static xml_reader_t *ReaderCreate( xml_t *p_xml, stream_t *p_stream )
p_reader->pf_name = ReaderName;
p_reader->pf_value = ReaderValue;
p_reader->pf_next_attr = ReaderNextAttr;
p_reader->pf_use_dtd = ReaderUseDTD;
return p_reader;
}
......@@ -161,6 +160,17 @@ static void ReaderDelete( xml_reader_t *p_reader )
free( p_reader );
}
static int ReaderUseDTD ( xml_reader_t *p_reader, vlc_bool_t b_use )
{
/* Activate DTD validation */
xmlTextReaderSetParserProp( p_reader->p_sys->p_reader,
XML_PARSER_DEFAULTATTRS, b_use );
xmlTextReaderSetParserProp( p_reader->p_sys->p_reader,
XML_PARSER_VALIDATE, b_use );
return VLC_SUCCESS;
}
static int ReaderRead( xml_reader_t *p_reader )
{
int i_ret = xmlTextReaderRead( p_reader->p_sys->p_reader );
......
......@@ -108,6 +108,8 @@ static char *ReaderName( xml_reader_t * );
static char *ReaderValue( xml_reader_t * );
static int ReaderNextAttr( xml_reader_t * );
static int ReaderUseDTD ( xml_reader_t *, vlc_bool_t );
static void CatalogLoad( xml_t *, const char * );
static void CatalogAdd( xml_t *, const char *, const char *, const char * );
......@@ -208,6 +210,7 @@ static xml_reader_t *ReaderCreate( xml_t *p_xml, stream_t *s )
p_reader->pf_name = ReaderName;
p_reader->pf_value = ReaderValue;
p_reader->pf_next_attr = ReaderNextAttr;
p_reader->pf_use_dtd = ReaderUseDTD;
return p_reader;
}
......@@ -219,6 +222,11 @@ static void ReaderDelete( xml_reader_t *p_reader )
free( p_reader );
}
static int ReaderUseDTD ( xml_reader_t *p_reader, vlc_bool_t b_use )
{
return VLC_EGENERIC;
}
static int ReaderRead( xml_reader_t *p_reader )
{
XTag *p_child;
......
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