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

Namespace/rename XML encode/decode functions

parent 09bb0203
...@@ -88,8 +88,33 @@ static inline int vlc_ascii_strncasecmp( const char *psz1, const char *psz2, siz ...@@ -88,8 +88,33 @@ static inline int vlc_ascii_strncasecmp( const char *psz1, const char *psz2, siz
return d; return d;
} }
VLC_API void resolve_xml_special_chars( char *psz_value ); /**
VLC_API char * convert_xml_special_chars( const char *psz_content ); * Decodes XML entities.
*
* Decodes a null-terminated UTF-8 string of XML character data into a regular
* nul-terminated UTF-8 string. In other words, replaces XML entities and
* numerical character references with the corresponding characters.
*
* This function operates in place (the output is always of smaller or equal
* length than the input) and always succeeds.
*
* \param str null-terminated string [IN/OUT]
*/
VLC_API void vlc_xml_decode(char *st);
/**
* Encodes XML entites.
*
* Substitutes unsafe characters in a null-terminated UTF-8 strings with an
* XML entity or numerical character reference.
*
* \param str null terminated UTF-8 string
* \return On success, a heap-allocated null-terminated string is returned.
* If the input string was not a valid UTF-8 sequence, NULL is returned and
* errno is set to EILSEQ.
* If there was not enough memory, NULL is returned and errno is to ENOMEM.
*/
VLC_API char *vlc_xml_encode(const char *str) VLC_MALLOC;
VLC_API char * vlc_b64_encode_binary( const uint8_t *, size_t ); VLC_API char * vlc_b64_encode_binary( const uint8_t *, size_t );
VLC_API char * vlc_b64_encode( const char * ); VLC_API char * vlc_b64_encode( const char * );
...@@ -109,7 +134,7 @@ static inline char *str_format( input_thread_t *input, const char *fmt ) ...@@ -109,7 +134,7 @@ static inline char *str_format( input_thread_t *input, const char *fmt )
return s2; return s2;
} }
VLC_API void filename_sanitize( char * ); VLC_API void filename_sanitize( char * );
VLC_API void path_sanitize( char * ); VLC_API void path_sanitize( char * );
VLC_API time_t str_duration( const char * ); VLC_API time_t str_duration( const char * );
......
...@@ -1379,7 +1379,7 @@ static int Request( access_t *p_access, uint64_t i_tell ) ...@@ -1379,7 +1379,7 @@ static int Request( access_t *p_access, uint64_t i_tell )
if( !p_sys->psz_icy_name ) if( !p_sys->psz_icy_name )
free( psz_tmp ); free( psz_tmp );
else else
resolve_xml_special_chars( p_sys->psz_icy_name ); vlc_xml_decode( p_sys->psz_icy_name );
msg_Dbg( p_access, "Icy-Name: %s", p_sys->psz_icy_name ); msg_Dbg( p_access, "Icy-Name: %s", p_sys->psz_icy_name );
input_thread_t *p_input = p_access->p_input; input_thread_t *p_input = p_access->p_input;
if ( p_input ) if ( p_input )
...@@ -1401,7 +1401,7 @@ static int Request( access_t *p_access, uint64_t i_tell ) ...@@ -1401,7 +1401,7 @@ static int Request( access_t *p_access, uint64_t i_tell )
if( !p_sys->psz_icy_genre ) if( !p_sys->psz_icy_genre )
free( psz_tmp ); free( psz_tmp );
else else
resolve_xml_special_chars( p_sys->psz_icy_genre ); vlc_xml_decode( p_sys->psz_icy_genre );
msg_Dbg( p_access, "Icy-Genre: %s", p_sys->psz_icy_genre ); msg_Dbg( p_access, "Icy-Genre: %s", p_sys->psz_icy_genre );
input_thread_t *p_input = p_access->p_input; input_thread_t *p_input = p_access->p_input;
if( p_input ) if( p_input )
......
...@@ -104,7 +104,7 @@ struct node { ...@@ -104,7 +104,7 @@ struct node {
inline static node* new_node( char *name ) inline static node* new_node( char *name )
{ {
node *n = (node*) calloc( 1, sizeof(node) ); node *n = (node*) calloc( 1, sizeof(node) );
n->name = convert_xml_special_chars( name ); n->name = vlc_xml_encode( name );
return n; return n;
} }
...@@ -537,7 +537,7 @@ static int WriteXSPF( char **pp_buffer, vlc_array_t *p_filenames, ...@@ -537,7 +537,7 @@ static int WriteXSPF( char **pp_buffer, vlc_array_t *p_filenames,
const char *psz_zippath ) const char *psz_zippath )
{ {
char *psz_zip = strrchr( psz_zippath, DIR_SEP_CHAR ); char *psz_zip = strrchr( psz_zippath, DIR_SEP_CHAR );
psz_zip = convert_xml_special_chars( psz_zip ? (psz_zip+1) : psz_zippath ); psz_zip = vlc_xml_encode( psz_zip ? (psz_zip+1) : psz_zippath );
if( asprintf( pp_buffer, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" if( asprintf( pp_buffer, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<playlist version=\"1\" xmlns=\"http://xspf.org/ns/0/\" " "<playlist version=\"1\" xmlns=\"http://xspf.org/ns/0/\" "
...@@ -575,8 +575,7 @@ static int WriteXSPF( char **pp_buffer, vlc_array_t *p_filenames, ...@@ -575,8 +575,7 @@ static int WriteXSPF( char **pp_buffer, vlc_array_t *p_filenames,
{ {
/* Extract file name */ /* Extract file name */
char *psz_file = strrchr( psz_name, '/' ); char *psz_file = strrchr( psz_name, '/' );
psz_file = convert_xml_special_chars( psz_file ? psz_file = vlc_xml_encode( psz_file ? (psz_file+1) : psz_name );
(psz_file+1) : psz_name );
/* Build full MRL */ /* Build full MRL */
char *psz_path = strdup( psz_pathtozip ); char *psz_path = strdup( psz_pathtozip );
......
...@@ -459,7 +459,7 @@ static text_segment_t *ParseTTMLSubtitles( decoder_t *p_dec, subpicture_updater_ ...@@ -459,7 +459,7 @@ static text_segment_t *ParseTTMLSubtitles( decoder_t *p_dec, subpicture_updater_
else if ( p_current_segment->psz_text == NULL ) else if ( p_current_segment->psz_text == NULL )
{ {
p_current_segment->psz_text = strdup( node ); p_current_segment->psz_text = strdup( node );
resolve_xml_special_chars( p_current_segment->psz_text ); vlc_xml_decode( p_current_segment->psz_text );
} }
else else
{ {
...@@ -470,7 +470,7 @@ static text_segment_t *ParseTTMLSubtitles( decoder_t *p_dec, subpicture_updater_ ...@@ -470,7 +470,7 @@ static text_segment_t *ParseTTMLSubtitles( decoder_t *p_dec, subpicture_updater_
free( p_current_segment->psz_text ); free( p_current_segment->psz_text );
p_current_segment->psz_text = psz_text; p_current_segment->psz_text = psz_text;
// Don't process text multiple time, just check for the appended section // Don't process text multiple time, just check for the appended section
resolve_xml_special_chars( p_current_segment->psz_text + i_previous_len ); vlc_xml_decode( p_current_segment->psz_text + i_previous_len );
} }
} }
} }
......
...@@ -119,7 +119,7 @@ static void ReadElement( xml_reader_t *p_xml_reader, char **ppsz_txt ) ...@@ -119,7 +119,7 @@ static void ReadElement( xml_reader_t *p_xml_reader, char **ppsz_txt )
xml_ReaderNextNode( p_xml_reader, &psz_node ); xml_ReaderNextNode( p_xml_reader, &psz_node );
free( *ppsz_txt ); free( *ppsz_txt );
*ppsz_txt = strdup( psz_node ); *ppsz_txt = strdup( psz_node );
resolve_xml_special_chars( *ppsz_txt ); vlc_xml_decode( *ppsz_txt );
/* Read the end element */ /* Read the end element */
xml_ReaderNextNode( p_xml_reader, &psz_node ); xml_ReaderNextNode( p_xml_reader, &psz_node );
...@@ -214,7 +214,7 @@ static void ProcessEntry( int *pi_n_entry, xml_reader_t *p_xml_reader, ...@@ -214,7 +214,7 @@ static void ProcessEntry( int *pi_n_entry, xml_reader_t *p_xml_reader,
ReadElement( p_xml_reader, &psz_moreinfo ); ReadElement( p_xml_reader, &psz_moreinfo );
else else
psz_moreinfo = strdup( psz_node ); psz_moreinfo = strdup( psz_node );
resolve_xml_special_chars( psz_moreinfo ); vlc_xml_decode( psz_moreinfo );
} }
else if( !strncasecmp( psz_node, "ABSTRACT", 8 ) ) else if( !strncasecmp( psz_node, "ABSTRACT", 8 ) )
ReadElement( p_xml_reader, &psz_description ); ReadElement( p_xml_reader, &psz_description );
...@@ -247,7 +247,7 @@ static void ProcessEntry( int *pi_n_entry, xml_reader_t *p_xml_reader, ...@@ -247,7 +247,7 @@ static void ProcessEntry( int *pi_n_entry, xml_reader_t *p_xml_reader,
if( asprintf( &psz_name, "%d. %s", *pi_n_entry, psz_title ) == -1) if( asprintf( &psz_name, "%d. %s", *pi_n_entry, psz_title ) == -1)
psz_name = strdup( psz_title ); psz_name = strdup( psz_title );
resolve_xml_special_chars( psz_href ); vlc_xml_decode( psz_href );
psz_mrl = ProcessMRL( psz_href, psz_prefix ); psz_mrl = ProcessMRL( psz_href, psz_prefix );
/* Add Time information */ /* Add Time information */
...@@ -373,7 +373,7 @@ static int Demux( demux_t *p_demux ) ...@@ -373,7 +373,7 @@ static int Demux( demux_t *p_demux )
else else
psz_txt = strdup( psz_node ); psz_txt = strdup( psz_node );
resolve_xml_special_chars( psz_txt ); vlc_xml_decode( psz_txt );
input_item_SetURL( p_current_input, psz_txt ); input_item_SetURL( p_current_input, psz_txt );
} }
else if( !strncasecmp( psz_node, "ABSTRACT", 8 ) ) else if( !strncasecmp( psz_node, "ABSTRACT", 8 ) )
...@@ -399,7 +399,7 @@ static int Demux( demux_t *p_demux ) ...@@ -399,7 +399,7 @@ static int Demux( demux_t *p_demux )
/* Create new input item */ /* Create new input item */
input_item_t *p_input; input_item_t *p_input;
psz_txt = strdup( psz_node ); psz_txt = strdup( psz_node );
resolve_xml_special_chars( psz_txt ); vlc_xml_decode( psz_txt );
p_input = input_item_New( psz_txt, psz_title_asx ); p_input = input_item_New( psz_txt, psz_title_asx );
input_item_CopyOptions( p_current_input, p_input ); input_item_CopyOptions( p_current_input, p_input );
input_item_node_AppendItem( p_subitems, p_input ); input_item_node_AppendItem( p_subitems, p_input );
......
...@@ -192,7 +192,7 @@ static int Demux( demux_t *p_demux ) ...@@ -192,7 +192,7 @@ static int Demux( demux_t *p_demux )
// Read the element name // Read the element name
if( !strcmp( node, "entry" ) ) if( !strcmp( node, "entry" ) )
{ {
resolve_xml_special_chars( psz_mrl ); vlc_xml_decode( psz_mrl );
p_input = input_item_New( psz_mrl, psz_title ); p_input = input_item_New( psz_mrl, psz_title );
if( psz_now ) if( psz_now )
input_item_SetNowPlaying( p_input, psz_now ); input_item_SetNowPlaying( p_input, psz_now );
......
...@@ -388,7 +388,7 @@ static bool save_data( track_elem_t *p_track, const char *psz_name, ...@@ -388,7 +388,7 @@ static bool save_data( track_elem_t *p_track, const char *psz_name,
return false; return false;
/* re-convert xml special characters inside psz_value */ /* re-convert xml special characters inside psz_value */
resolve_xml_special_chars( psz_value ); vlc_xml_decode( psz_value );
#define SAVE_INFO( name, value ) \ #define SAVE_INFO( name, value ) \
if( !strcmp( psz_name, name ) ) { p_track->value = strdup( psz_value ); } if( !strcmp( psz_name, name ) ) { p_track->value = strdup( psz_value ); }
......
...@@ -252,8 +252,8 @@ static int Demux( demux_t *p_demux ) ...@@ -252,8 +252,8 @@ static int Demux( demux_t *p_demux )
continue; continue;
} }
resolve_xml_special_chars( psz_item_mrl ); vlc_xml_decode( psz_item_mrl );
resolve_xml_special_chars( psz_item_name ); vlc_xml_decode( psz_item_name );
p_input = input_item_New( psz_item_mrl, psz_item_name ); p_input = input_item_New( psz_item_mrl, psz_item_name );
FREENULL( psz_item_mrl ); FREENULL( psz_item_mrl );
FREENULL( psz_item_name ); FREENULL( psz_item_name );
...@@ -283,7 +283,7 @@ static int Demux( demux_t *p_demux ) ...@@ -283,7 +283,7 @@ static int Demux( demux_t *p_demux )
/* Add the global art url to this item, if any */ /* Add the global art url to this item, if any */
if( psz_art_url ) if( psz_art_url )
{ {
resolve_xml_special_chars( psz_art_url ); vlc_xml_decode( psz_art_url );
input_item_SetArtURL( p_input, psz_art_url ); input_item_SetArtURL( p_input, psz_art_url );
} }
......
...@@ -245,7 +245,7 @@ static int Demux( demux_t *p_demux ) ...@@ -245,7 +245,7 @@ static int Demux( demux_t *p_demux )
vlc_gc_decref( p_input ); vlc_gc_decref( p_input );
if( psz_qtnext ) if( psz_qtnext )
{ {
resolve_xml_special_chars( psz_qtnext ); vlc_xml_decode( psz_qtnext );
p_input = input_item_New( psz_qtnext, NULL ); p_input = input_item_New( psz_qtnext, NULL );
input_item_node_AppendItem( p_subitems, p_input ); input_item_node_AppendItem( p_subitems, p_input );
vlc_gc_decref( p_input ); vlc_gc_decref( p_input );
......
...@@ -171,7 +171,7 @@ static int DemuxGenre( demux_t *p_demux, xml_reader_t *p_xml_reader, ...@@ -171,7 +171,7 @@ static int DemuxGenre( demux_t *p_demux, xml_reader_t *p_xml_reader,
psz_name ) != -1 ) psz_name ) != -1 )
{ {
input_item_t *p_input; input_item_t *p_input;
resolve_xml_special_chars( psz_mrl ); vlc_xml_decode( psz_mrl );
p_input = input_item_New( psz_mrl, psz_name ); p_input = input_item_New( psz_mrl, psz_name );
input_item_CopyOptions( p_input_node->p_item, p_input ); input_item_CopyOptions( p_input_node->p_item, p_input );
free( psz_mrl ); free( psz_mrl );
...@@ -319,7 +319,7 @@ static int DemuxStation( demux_t *p_demux, xml_reader_t *p_xml_reader, ...@@ -319,7 +319,7 @@ static int DemuxStation( demux_t *p_demux, xml_reader_t *p_xml_reader,
if( likely(psz_mrl != NULL) ) if( likely(psz_mrl != NULL) )
{ {
resolve_xml_special_chars( psz_mrl ); vlc_xml_decode( psz_mrl );
p_input = input_item_New( psz_mrl, psz_name ); p_input = input_item_New( psz_mrl, psz_name );
free( psz_mrl ); free( psz_mrl );
} }
......
...@@ -526,7 +526,7 @@ static bool set_item_info SIMPLE_INTERFACE ...@@ -526,7 +526,7 @@ static bool set_item_info SIMPLE_INTERFACE
return false; return false;
/* re-convert xml special characters inside psz_value */ /* re-convert xml special characters inside psz_value */
resolve_xml_special_chars(psz_value); vlc_xml_decode(psz_value);
/* handle each info element in a separate "if" clause */ /* handle each info element in a separate "if" clause */
if (!strcmp(psz_name, "title")) if (!strcmp(psz_name, "title"))
...@@ -561,7 +561,7 @@ static bool set_option SIMPLE_INTERFACE ...@@ -561,7 +561,7 @@ static bool set_option SIMPLE_INTERFACE
return false; return false;
/* re-convert xml special characters inside psz_value */ /* re-convert xml special characters inside psz_value */
resolve_xml_special_chars(psz_value); vlc_xml_decode(psz_value);
input_item_AddOption(p_input, psz_value, 0); input_item_AddOption(p_input, psz_value, 0);
...@@ -599,7 +599,7 @@ static bool parse_extension_node COMPLEX_INTERFACE ...@@ -599,7 +599,7 @@ static bool parse_extension_node COMPLEX_INTERFACE
free(psz_title); free(psz_title);
psz_title = strdup(value); psz_title = strdup(value);
if (likely(psz_title != NULL)) if (likely(psz_title != NULL))
resolve_xml_special_chars(psz_title); vlc_xml_decode(psz_title);
} }
/* extension attribute: application */ /* extension attribute: application */
else if (!strcmp(name, "application")) else if (!strcmp(name, "application"))
......
...@@ -112,7 +112,7 @@ static int vlclua_resolve_xml_special_chars( lua_State *L ) ...@@ -112,7 +112,7 @@ static int vlclua_resolve_xml_special_chars( lua_State *L )
lua_remove( L, 1 ); /* remove elements to prevent being limited by lua_remove( L, 1 ); /* remove elements to prevent being limited by
* the stack's size (this function will work with * the stack's size (this function will work with
* up to (stack size - 1) arguments */ * up to (stack size - 1) arguments */
resolve_xml_special_chars( psz_string ); vlc_xml_decode( psz_string );
lua_pushstring( L, psz_string ); lua_pushstring( L, psz_string );
free( psz_string ); free( psz_string );
} }
...@@ -125,7 +125,7 @@ static int vlclua_convert_xml_special_chars( lua_State *L ) ...@@ -125,7 +125,7 @@ static int vlclua_convert_xml_special_chars( lua_State *L )
int i; int i;
for( i = 1; i <= i_top; i++ ) for( i = 1; i <= i_top; i++ )
{ {
char *psz_string = convert_xml_special_chars( luaL_checkstring(L,1) ); char *psz_string = vlc_xml_encode( luaL_checkstring(L,1) );
lua_remove( L, 1 ); lua_remove( L, 1 );
lua_pushstring( L, psz_string ); lua_pushstring( L, psz_string );
free( psz_string ); free( psz_string );
......
...@@ -526,7 +526,7 @@ static int Install( addons_storage_t *p_storage, addon_entry_t *p_entry ) ...@@ -526,7 +526,7 @@ static int Install( addons_storage_t *p_storage, addon_entry_t *p_entry )
#define WRITE_WITH_ENTITIES( formatstring, varname ) \ #define WRITE_WITH_ENTITIES( formatstring, varname ) \
if ( varname ) \ if ( varname ) \
{\ {\
psz_tempstring = convert_xml_special_chars( varname );\ psz_tempstring = vlc_xml_encode( varname );\
fprintf( p_catalog, formatstring, psz_tempstring );\ fprintf( p_catalog, formatstring, psz_tempstring );\
free( psz_tempstring );\ free( psz_tempstring );\
}\ }\
...@@ -598,7 +598,7 @@ static int WriteCatalog( addons_storage_t *p_storage, ...@@ -598,7 +598,7 @@ static int WriteCatalog( addons_storage_t *p_storage,
} }
if ( p_entry->psz_source_module ) if ( p_entry->psz_source_module )
psz_tempstring = convert_xml_special_chars( p_entry->psz_source_module ); psz_tempstring = vlc_xml_encode( p_entry->psz_source_module );
char *psz_uuid = addons_uuid_to_psz( ( const addon_uuid_t * ) & p_entry->uuid ); char *psz_uuid = addons_uuid_to_psz( ( const addon_uuid_t * ) & p_entry->uuid );
fprintf( p_catalog, "\t\t<addon source=\"%s\" type=\"%s\" id=\"%s\" " fprintf( p_catalog, "\t\t<addon source=\"%s\" type=\"%s\" id=\"%s\" "
...@@ -635,7 +635,7 @@ static int WriteCatalog( addons_storage_t *p_storage, ...@@ -635,7 +635,7 @@ static int WriteCatalog( addons_storage_t *p_storage,
fprintf( p_catalog, "\t\t\t</authorship>\n" ); fprintf( p_catalog, "\t\t\t</authorship>\n" );
FOREACH_ARRAY( addon_file_t *p_file, p_entry->files ) FOREACH_ARRAY( addon_file_t *p_file, p_entry->files )
psz_tempstring = convert_xml_special_chars( p_file->psz_filename ); psz_tempstring = vlc_xml_encode( p_file->psz_filename );
fprintf( p_catalog, "\t\t\t<resource type=\"%s\">%s</resource>\n", fprintf( p_catalog, "\t\t\t<resource type=\"%s\">%s</resource>\n",
getTypePsz( p_file->e_filetype ), psz_tempstring ); getTypePsz( p_file->e_filetype ), psz_tempstring );
free( psz_tempstring ); free( psz_tempstring );
......
...@@ -62,7 +62,7 @@ static void DoChildren( playlist_export_t *p_export, playlist_item_t *p_root ) ...@@ -62,7 +62,7 @@ static void DoChildren( playlist_export_t *p_export, playlist_item_t *p_root )
char* psz_name = NULL; char* psz_name = NULL;
char *psz_tmp = input_item_GetName( p_current->p_input ); char *psz_tmp = input_item_GetName( p_current->p_input );
if( psz_tmp ) if( psz_tmp )
psz_name = convert_xml_special_chars( psz_tmp ); psz_name = vlc_xml_encode( psz_tmp );
free( psz_tmp ); free( psz_tmp );
if( psz_name ) if( psz_name )
...@@ -70,7 +70,7 @@ static void DoChildren( playlist_export_t *p_export, playlist_item_t *p_root ) ...@@ -70,7 +70,7 @@ static void DoChildren( playlist_export_t *p_export, playlist_item_t *p_root )
char* psz_artist = NULL; char* psz_artist = NULL;
psz_tmp = input_item_GetArtist( p_current->p_input ); psz_tmp = input_item_GetArtist( p_current->p_input );
if( psz_tmp ) if( psz_tmp )
psz_artist = convert_xml_special_chars( psz_tmp ); psz_artist = vlc_xml_encode( psz_tmp );
free( psz_tmp ); free( psz_tmp );
mtime_t i_duration = input_item_GetDuration( p_current->p_input ); mtime_t i_duration = input_item_GetDuration( p_current->p_input );
......
...@@ -45,7 +45,7 @@ static char *input_xml( input_item_t *p_item, char *(*func)(input_item_t *) ) ...@@ -45,7 +45,7 @@ static char *input_xml( input_item_t *p_item, char *(*func)(input_item_t *) )
char *tmp = func( p_item ); char *tmp = func( p_item );
if( tmp == NULL ) if( tmp == NULL )
return NULL; return NULL;
char *ret = convert_xml_special_chars( tmp ); char *ret = vlc_xml_encode( tmp );
free( tmp ); free( tmp );
return ret; return ret;
} }
...@@ -161,7 +161,7 @@ xspfexportitem_end: ...@@ -161,7 +161,7 @@ xspfexportitem_end:
if ( psz_src[0] == ':' ) if ( psz_src[0] == ':' )
psz_src++; psz_src++;
psz_ret = convert_xml_special_chars( psz_src ); psz_ret = vlc_xml_encode( psz_src );
if ( psz_ret == NULL ) if ( psz_ret == NULL )
continue; continue;
...@@ -189,7 +189,7 @@ static void xspf_extension_item( playlist_item_t *p_item, FILE *p_file, ...@@ -189,7 +189,7 @@ static void xspf_extension_item( playlist_item_t *p_item, FILE *p_file,
int i; int i;
char *psz_temp = NULL; char *psz_temp = NULL;
if( p_item->p_input->psz_name ) if( p_item->p_input->psz_name )
psz_temp = convert_xml_special_chars( p_item->p_input->psz_name ); psz_temp = vlc_xml_encode( p_item->p_input->psz_name );
fprintf( p_file, "\t\t<vlc:node title=\"%s\">\n", fprintf( p_file, "\t\t<vlc:node title=\"%s\">\n",
psz_temp ? psz_temp : "" ); psz_temp ? psz_temp : "" );
free( psz_temp ); free( psz_temp );
...@@ -234,7 +234,7 @@ int xspf_export_playlist( vlc_object_t *p_this ) ...@@ -234,7 +234,7 @@ int xspf_export_playlist( vlc_object_t *p_this )
if( !p_node ) return VLC_SUCCESS; if( !p_node ) return VLC_SUCCESS;
/* save name of the playlist node */ /* save name of the playlist node */
psz_temp = convert_xml_special_chars( p_node->p_input->psz_name ); psz_temp = vlc_xml_encode( p_node->p_input->psz_name );
if( *psz_temp ) if( *psz_temp )
{ {
fprintf( p_export->p_file, "\t<title>%s</title>\n", psz_temp ); fprintf( p_export->p_file, "\t<title>%s</title>\n", psz_temp );
......
...@@ -66,7 +66,6 @@ config_ResetAll ...@@ -66,7 +66,6 @@ config_ResetAll
config_SaveConfigFile config_SaveConfigFile
config_StringEscape config_StringEscape
config_StringUnescape config_StringUnescape
convert_xml_special_chars
date_Change date_Change
date_Decrement date_Decrement
date_Get date_Get
...@@ -363,7 +362,6 @@ playlist_VolumeSet ...@@ -363,7 +362,6 @@ playlist_VolumeSet
playlist_VolumeUp playlist_VolumeUp
playlist_MuteSet playlist_MuteSet
playlist_MuteGet playlist_MuteGet
resolve_xml_special_chars
sdp_AddAttribute sdp_AddAttribute
sdp_AddMedia sdp_AddMedia
secstotimestr secstotimestr
...@@ -692,6 +690,8 @@ xml_Delete ...@@ -692,6 +690,8 @@ xml_Delete
xml_ReaderCreate xml_ReaderCreate
xml_ReaderDelete xml_ReaderDelete
xml_ReaderReset xml_ReaderReset
vlc_xml_decode
vlc_xml_encode
vlc_keycode2str vlc_keycode2str
vlc_str2keycode vlc_str2keycode
fingerprinter_Create fingerprinter_Create
......
...@@ -265,7 +265,7 @@ static size_t httpd_HtmlError (char **body, int code, const char *url) ...@@ -265,7 +265,7 @@ static size_t httpd_HtmlError (char **body, int code, const char *url)
const char *errname = httpd_ReasonFromCode (code); const char *errname = httpd_ReasonFromCode (code);
assert (errname); assert (errname);
char *url_Encoded = convert_xml_special_chars (url ? url : ""); char *url_Encoded = vlc_xml_encode (url ? url : "");
int res = asprintf (body, int res = asprintf (body,
"<?xml version=\"1.0\" encoding=\"ascii\" ?>\n" "<?xml version=\"1.0\" encoding=\"ascii\" ?>\n"
......
...@@ -35,7 +35,7 @@ static void decode (const char *in, const char *out) ...@@ -35,7 +35,7 @@ static void decode (const char *in, const char *out)
printf ("\"%s\" -> \"%s\" ?\n", in, out); printf ("\"%s\" -> \"%s\" ?\n", in, out);
strcpy (buf, in); strcpy (buf, in);
resolve_xml_special_chars (buf); vlc_xml_decode (buf);
if (strcmp (buf, out)) if (strcmp (buf, out))
{ {
...@@ -49,7 +49,7 @@ static void encode (const char *in, const char *out) ...@@ -49,7 +49,7 @@ static void encode (const char *in, const char *out)
char *buf; char *buf;
printf ("\"%s\" -> \"%s\" ?\n", in, out); printf ("\"%s\" -> \"%s\" ?\n", in, out);
buf = convert_xml_special_chars (in); buf = vlc_xml_encode (in);
if (strcmp (buf, out)) if (strcmp (buf, out))
{ {
......
...@@ -189,11 +189,7 @@ static int cmp_entity (const void *key, const void *elem) ...@@ -189,11 +189,7 @@ static int cmp_entity (const void *key, const void *elem)
return strncmp (name, ent->psz_entity, strlen (ent->psz_entity)); return strncmp (name, ent->psz_entity, strlen (ent->psz_entity));
} }
/** void vlc_xml_decode( char *psz_value )
* Converts "&lt;", "&gt;" and "&amp;" to "<", ">" and "&"
* \param string to convert
*/
void resolve_xml_special_chars( char *psz_value )
{ {
char *p_pos = psz_value; char *p_pos = psz_value;
...@@ -285,13 +281,7 @@ void resolve_xml_special_chars( char *psz_value ) ...@@ -285,13 +281,7 @@ void resolve_xml_special_chars( char *psz_value )
*p_pos = '\0'; *p_pos = '\0';
} }
/** char *vlc_xml_encode (const char *str)
* XML-encode an UTF-8 string
* \param str null-terminated UTF-8 byte sequence to XML-encode
* \return XML encoded string or NULL on error
* (errno is set to ENOMEM or EILSEQ as appropriate)
*/
char *convert_xml_special_chars (const char *str)
{ {
assert (str != NULL); assert (str != NULL);
......
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