Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-1.1
Commits
7a0efcc7
Commit
7a0efcc7
authored
May 10, 2009
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
XSPF: use make_URI, should fix #2731
parent
d10d2dc0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
82 deletions
+3
-82
modules/misc/playlist/xspf.c
modules/misc/playlist/xspf.c
+3
-82
No files found.
modules/misc/playlist/xspf.c
View file @
7a0efcc7
...
...
@@ -34,14 +34,13 @@
#include <vlc_playlist.h>
#include <vlc_input.h>
#include <vlc_strings.h>
#include <vlc_
charset
.h>
#include <vlc_
url
.h>
#include "xspf.h"
#include <assert.h>
static
void
xspf_export_item
(
playlist_item_t
*
,
FILE
*
,
int
*
);
static
void
xspf_extension_item
(
playlist_item_t
*
,
FILE
*
,
int
*
);
static
char
*
assertUTF8URI
(
const
char
*
);
/**
* \brief Prints the XSPF header to file, writes each item by xspf_export_item()
...
...
@@ -143,7 +142,7 @@ static void xspf_export_item( playlist_item_t *p_item, FILE *p_file,
if
(
psz_uri
&&
*
psz_uri
)
{
psz
=
assertUTF8
URI
(
psz_uri
);
psz
=
make_
URI
(
psz_uri
);
fprintf
(
p_file
,
"
\t\t\t
<location>%s</location>
\n
"
,
psz
);
free
(
psz
);
}
...
...
@@ -213,7 +212,7 @@ static void xspf_export_item( playlist_item_t *p_item, FILE *p_file,
if
(
psz
==
NULL
)
psz
=
strdup
(
""
);
if
(
!
EMPTY_STR
(
psz
)
)
{
psz_uri
=
assertUTF8
URI
(
psz
);
psz_uri
=
make_
URI
(
psz
);
fprintf
(
p_file
,
"
\t\t\t
<image>%s</image>
\n
"
,
psz_uri
);
free
(
psz_uri
);
}
...
...
@@ -288,81 +287,3 @@ static void xspf_extension_item( playlist_item_t *p_item, FILE *p_file,
return
;
}
/**
* \param psz_name the location of the media ressource (e.g. local file,
* device, network stream, etc.)
* \return a new char buffer which asserts that the location is valid UTF-8
* and a valid URI
* \note the returned buffer must be freed, when it isn't used anymore
*/
static
char
*
assertUTF8URI
(
const
char
*
psz_name
)
{
char
*
psz_ret
=
NULL
;
/**< the new result buffer to return */
char
*
psz_s
=
NULL
,
*
psz_d
=
NULL
;
/**< src & dest pointers for URI conversion */
bool
b_uri_is_file
=
false
;
/**< we do additional %-encoding if the URI is a file:// one */
/* max. 3x for URI conversion (percent escaping) and
8 bytes for "file://" and NULL-termination */
psz_ret
=
(
char
*
)
malloc
(
strlen
(
psz_name
)
*
6
*
3
+
8
);
if
(
!
psz_ret
)
return
NULL
;
/** \todo check for a valid scheme part preceding the colon */
if
(
strstr
(
psz_s
,
"://"
)
!=
NULL
)
{
size_t
i_delim
=
strcspn
(
psz_s
,
":"
);
i_delim
++
;
/* skip the ':' */
strncpy
(
psz_ret
,
psz_s
,
i_delim
);
psz_d
=
psz_ret
+
i_delim
;
if
(
!
strncmp
(
psz_s
,
"file://"
,
7
)
)
b_uri_is_file
=
true
;
psz_s
+=
i_delim
;
}
/* assume "file" scheme if no scheme-part is included */
else
{
strcpy
(
psz_ret
,
"file://"
);
psz_d
=
psz_ret
+
7
;
b_uri_is_file
=
true
;
}
while
(
*
psz_s
)
{
/* percent-encode all non-ASCII and the XML special characters and the percent sign itself */
if
(
*
psz_s
&
B10000000
||
*
psz_s
==
'<'
||
*
psz_s
==
'>'
||
*
psz_s
==
'&'
||
*
psz_s
==
' '
||
*
psz_s
==
'+'
||
*
psz_s
==
'%'
||
*
psz_s
==
'\\'
||
(
b_uri_is_file
&&
(
*
psz_s
==
':'
||
*
psz_s
==
'"'
||
*
psz_s
==
'?'
||
*
psz_s
==
'#'
||
*
psz_s
==
'['
||
*
psz_s
==
']'
||
*
psz_s
==
'@'
)
)
)
{
*
psz_d
++
=
'%'
;
*
psz_d
++
=
hexchars
[(
*
psz_s
>>
4
)
&
B00001111
];
*
psz_d
++
=
hexchars
[
*
psz_s
&
B00001111
];
}
else
{
*
psz_d
++
=
*
psz_s
;
}
psz_s
++
;
}
*
psz_d
=
'\0'
;
return
(
char
*
)
realloc
(
psz_ret
,
strlen
(
psz_ret
)
+
1
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment