fprintf( p_export->p_file, "\t</trackList>\n" );
/* export the tree structure in <extension> */
- fprintf( p_export->p_file, "\t<extension>\n" );
+ fprintf( p_export->p_file, "\t<extension application=\"http://www.videolan.org/vlc/playlist/0\">\n" );
i_count = 0;
for( i = 0; i < p_node->i_children; i++ )
{
/* -> the track number */
psz = input_item_GetTrackNum( p_item->p_input );
if( psz == NULL ) psz = strdup( "" );
- if( psz )
+ if( psz && *psz )
{
- if( *psz )
- {
- fprintf( p_file, "\t\t\t<trackNum>%i</trackNum>\n", atoi( psz ) );
- }
+ int i_tracknum = atoi( psz );
+ if( i_tracknum > 0 )
+ fprintf( p_file, "\t\t\t<trackNum>%i</trackNum>\n", i_tracknum );
}
free( psz );
psz = input_item_GetArtURL( p_item->p_input );
if( psz == NULL ) psz = strdup( "" );
- psz_temp = convert_xml_special_chars( psz );
- free( psz );
- if( !EMPTY_STR( psz_temp ) )
+ if( !EMPTY_STR( psz ) )
{
- fprintf( p_file, "\t\t\t<image>%s</image>\n", psz_temp );
+ psz_uri = assertUTF8URI( psz );
+ fprintf( p_file, "\t\t\t<image>%s</image>\n", psz_uri );
+ free( psz_uri );
}
- free( psz_temp );
+ free( psz );
xspfexportitem_end:
/* -> the duration */
char *psz_temp;
psz_temp = convert_xml_special_chars( p_item->p_input->psz_name );
fprintf( p_file, "\t\t<node title=\"%s\">\n",
- *psz_temp ? p_item->p_input->psz_name : "" );
+ *psz_temp ? psz_temp : "" );
free( psz_temp );
for( i = 0; i < p_item->i_children; i++ )
{
char *psz_ret = NULL; /**< the new result buffer to return */
char *psz_s = NULL, *psz_d = NULL; /**< src & dest pointers for URI conversion */
- vlc_bool_t b_name_is_uri = VLC_FALSE;
+ vlc_bool_t b_uri_is_file = VLC_FALSE; /**< we do additional %-encoding if the URI is a file:// one */
if( !psz_name || !*psz_name )
return NULL;
return NULL;
/** \todo check for a valid scheme part preceding the colon */
- if( strchr( psz_s, ':' ) )
+ size_t i_delim = strcspn( psz_s, ":" );
+ if( i_delim != strlen( psz_s ) )
{
- psz_d = psz_ret;
- b_name_is_uri = VLC_TRUE;
+ i_delim++; /* skip the ':' */
+ strncpy( psz_ret, psz_s, i_delim );
+ psz_d = psz_ret + i_delim;
+ psz_s += i_delim;
+
+ if( !strncmp( psz_s, "file://", 7 ) )
+ b_uri_is_file = VLC_TRUE;
}
/* assume "file" scheme if no scheme-part is included */
else
{
strcpy( psz_ret, "file://" );
psz_d = psz_ret + 7;
+ b_uri_is_file = VLC_TRUE;
}
while( *psz_s )
*psz_s == '>' ||
*psz_s == '&' ||
*psz_s == ' ' ||
- ( *psz_s == '%' && !b_name_is_uri ) )
+ ( b_uri_is_file && (
+ *psz_s == ':' ||
+ *psz_s == '"' ||
+ *psz_s == '?' ||
+ *psz_s == '#' ||
+ *psz_s == '[' ||
+ *psz_s == ']' ||
+ *psz_s == '@' ||
+ *psz_s == '%' )
+ )
+ )
{
*psz_d++ = '%';
*psz_d++ = hexchars[(*psz_s >> 4) & B00001111];