Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
6f15ed52
Commit
6f15ed52
authored
Nov 29, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Namespace/rename vlc URI decode/encode functions
parent
04fb7e89
Changes
22
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
86 additions
and
72 deletions
+86
-72
include/vlc_url.h
include/vlc_url.h
+45
-6
modules/access/archive/access.c
modules/access/archive/access.c
+1
-1
modules/access/directory.c
modules/access/directory.c
+1
-1
modules/access/file.c
modules/access/file.c
+1
-1
modules/access/ftp.c
modules/access/ftp.c
+1
-1
modules/access/jack.c
modules/access/jack.c
+1
-1
modules/access/rar/access.c
modules/access/rar/access.c
+1
-1
modules/access/rar/stream.c
modules/access/rar/stream.c
+1
-1
modules/access/sftp.c
modules/access/sftp.c
+1
-1
modules/demux/playlist/playlist.c
modules/demux/playlist/playlist.c
+1
-1
modules/demux/playlist/ram.c
modules/demux/playlist/ram.c
+10
-10
modules/gui/macosx/PLModel.m
modules/gui/macosx/PLModel.m
+1
-1
modules/gui/macosx/VLCPlaylist.m
modules/gui/macosx/VLCPlaylist.m
+2
-2
modules/gui/macosx/VLCPlaylistInfo.m
modules/gui/macosx/VLCPlaylistInfo.m
+1
-1
modules/gui/qt4/input_manager.cpp
modules/gui/qt4/input_manager.cpp
+2
-2
modules/gui/qt4/menus.cpp
modules/gui/qt4/menus.cpp
+1
-1
modules/lua/libs/strings.c
modules/lua/libs/strings.c
+2
-3
modules/misc/audioscrobbler.c
modules/misc/audioscrobbler.c
+1
-1
src/input/item.c
src/input/item.c
+1
-1
src/libvlccore.sym
src/libvlccore.sym
+3
-3
src/test/url.c
src/test/url.c
+1
-1
src/text/url.c
src/text/url.c
+7
-31
No files found.
include/vlc_url.h
View file @
6f15ed52
...
...
@@ -57,6 +57,51 @@ VLC_API char *vlc_path2uri(const char *path, const char *scheme) VLC_MALLOC;
*/
VLC_API
char
*
vlc_uri2path
(
const
char
*
url
)
VLC_MALLOC
;
/**
* Decodes an URI component in place.
*
* Decodes one null-terminated UTF-8 URI component to aa null-terminated UTF-8
* string in place.
*
* See also vlc_uri_decode_duplicate() for the not-in-place variant.
*
* \warning <b>This function does NOT decode entire URIs.</b>
* URI can only be decoded (and encoded) one component at a time
* (e.g. the host name, one directory, the file name).
* Complete URIs are always "encoded" (or they are syntaxically invalid).
* See IETF RFC3986, especially §2.4 for details.
*
* \note URI encoding is <b>different</b> from Javascript escaping. Especially,
* white spaces and Unicode non-ASCII code points are encoded differently.
*
* \param str null-terminated component
* \return str is returned on success. NULL if str was not properly encoded.
*/
VLC_API
char
*
vlc_uri_decode
(
char
*
str
);
/**
* Decodes an URI component.
*
* See also vlc_uri_decode() for the in-place variant.
*
* \return a heap-allocated string on success or NULL on error.
*/
VLC_API
char
*
vlc_uri_decode_duplicate
(
const
char
*
str
)
VLC_MALLOC
;
/**
* Encodes a URI component.
*
* Substitutes URI-unsafe, URI delimiters and non-ASCII characters into their
* URI-encoded URI-safe representation. See also IETF RFC3986 §2.
*
* @param str nul-terminated UTF-8 representation of the component.
* @note Obviously, a URI containing nul bytes cannot be passed.
* @return heap-allocated string, or NULL if out of memory.
*/
VLC_API
char
*
vlc_uri_encode
(
const
char
*
str
)
VLC_MALLOC
;
/** @} */
struct
vlc_url_t
{
char
*
psz_protocol
;
...
...
@@ -70,12 +115,6 @@ struct vlc_url_t
char
*
psz_buffer
;
/* to be freed */
};
VLC_API
char
*
decode_URI_duplicate
(
const
char
*
psz
)
VLC_MALLOC
;
VLC_API
char
*
decode_URI
(
char
*
psz
);
VLC_API
char
*
encode_URI_component
(
const
char
*
psz
)
VLC_MALLOC
;
/** @} */
VLC_API
void
vlc_UrlParse
(
vlc_url_t
*
,
const
char
*
);
VLC_API
void
vlc_UrlClean
(
vlc_url_t
*
);
...
...
modules/access/archive/access.c
View file @
6f15ed52
...
...
@@ -317,7 +317,7 @@ int AccessOpen(vlc_object_t *p_object)
char
*
psz_name
=
psz_base
+
(
sep
-
p_access
->
psz_location
);
*
(
psz_name
++
)
=
'\0'
;
if
(
decode_URI
(
psz_base
)
==
NULL
)
if
(
vlc_uri_decode
(
psz_base
)
==
NULL
)
{
free
(
psz_base
);
return
VLC_EGENERIC
;
...
...
modules/access/directory.c
View file @
6f15ed52
...
...
@@ -163,7 +163,7 @@ input_item_t *DirRead(access_t *access)
}
/* Create an input item for the current entry */
char
*
encoded
=
encode_URI_component
(
entry
);
char
*
encoded
=
vlc_uri_encode
(
entry
);
if
(
unlikely
(
entry
==
NULL
))
continue
;
...
...
modules/access/file.c
View file @
6f15ed52
...
...
@@ -152,7 +152,7 @@ int FileOpen( vlc_object_t *p_this )
fd
=
vlc_dup
(
oldfd
);
else
if
(
*
end
==
'/'
&&
end
>
p_access
->
psz_location
)
{
char
*
name
=
decode_URI
_duplicate
(
end
-
1
);
char
*
name
=
vlc_uri_decode
_duplicate
(
end
-
1
);
if
(
name
!=
NULL
)
{
name
[
0
]
=
'.'
;
...
...
modules/access/ftp.c
View file @
6f15ed52
...
...
@@ -612,7 +612,7 @@ static int parseURL( vlc_url_t *url, const char *path, enum tls_mode_e mode )
if
(
strchr
(
"iI"
,
type
[
6
]
)
==
NULL
)
return
VLC_EGENERIC
;
/* ASCII and directory not supported */
}
decode_URI
(
url
->
psz_path
);
vlc_uri_decode
(
url
->
psz_path
);
return
VLC_SUCCESS
;
}
...
...
modules/access/jack.c
View file @
6f15ed52
...
...
@@ -514,7 +514,7 @@ static void Port_finder( demux_t *p_demux )
for
(
token
=
strtok_r
(
psz_expr
,
","
,
&
state
);
token
;
token
=
strtok_r
(
NULL
,
","
,
&
state
)
)
{
psz_uri
=
decode_URI
_duplicate
(
token
);
psz_uri
=
vlc_uri_decode
_duplicate
(
token
);
/* get the ports which match the regexp */
pp_jack_port_output
=
jack_get_ports
(
p_sys
->
p_jack_client
,
psz_uri
,
NULL
,
JackPortIsOutput
);
...
...
modules/access/rar/access.c
View file @
6f15ed52
...
...
@@ -153,7 +153,7 @@ int RarAccessOpen(vlc_object_t *object)
return
VLC_ENOMEM
;
name
++
;
decode_URI
(
base
);
vlc_uri_decode
(
base
);
stream_t
*
s
=
stream_UrlNew
(
access
,
base
);
if
(
!
s
||
RarProbe
(
s
))
...
...
modules/access/rar/stream.c
View file @
6f15ed52
...
...
@@ -113,7 +113,7 @@ int RarStreamOpen(vlc_object_t *object)
* (becareful about '\' and '/'.
*/
char
*
base
;
char
*
encoded
=
encode_URI_component
(
s
->
psz_url
);
char
*
encoded
=
vlc_uri_encode
(
s
->
psz_url
);
if
(
!
encoded
||
asprintf
(
&
base
,
"rar://%s"
,
encoded
)
<
0
)
base
=
NULL
;
free
(
encoded
);
...
...
modules/access/sftp.c
View file @
6f15ed52
...
...
@@ -475,7 +475,7 @@ static input_item_t* DirRead( access_t *p_access )
char
*
psz_full_uri
,
*
psz_uri
;
psz_uri
=
encode_URI_component
(
psz_file
);
psz_uri
=
vlc_uri_encode
(
psz_file
);
if
(
psz_uri
==
NULL
)
continue
;
...
...
modules/demux/playlist/playlist.c
View file @
6f15ed52
...
...
@@ -261,7 +261,7 @@ char *ProcessMRL( const char *psz_mrl, const char *psz_prefix )
/* This a relative path, prepend the prefix */
char
*
ret
;
char
*
postfix
=
encode_URI_component
(
psz_mrl
);
char
*
postfix
=
vlc_uri_encode
(
psz_mrl
);
/* FIXME: postfix may not be encoded correctly (esp. slashes) */
if
(
postfix
==
NULL
||
asprintf
(
&
ret
,
"%s%s"
,
psz_prefix
,
postfix
)
==
-
1
)
...
...
modules/demux/playlist/ram.c
View file @
6f15ed52
...
...
@@ -294,7 +294,7 @@ static int Demux( demux_t *p_demux )
}
else
if
(
!
strcmp
(
psz_param
,
"author"
)
)
{
psz_author
=
decode_URI
_duplicate
(
psz_value
);
psz_author
=
vlc_uri_decode
_duplicate
(
psz_value
);
EnsureUTF8
(
psz_author
);
}
else
if
(
!
strcmp
(
psz_param
,
"start"
)
...
...
@@ -320,12 +320,12 @@ static int Demux( demux_t *p_demux )
}
else
if
(
!
strcmp
(
psz_param
,
"title"
)
)
{
psz_title
=
decode_URI
_duplicate
(
psz_value
);
psz_title
=
vlc_uri_decode
_duplicate
(
psz_value
);
EnsureUTF8
(
psz_title
);
}
else
if
(
!
strcmp
(
psz_param
,
"copyright"
)
)
{
psz_copyright
=
decode_URI
_duplicate
(
psz_value
);
psz_copyright
=
vlc_uri_decode
_duplicate
(
psz_value
);
EnsureUTF8
(
psz_copyright
);
}
else
...
...
@@ -446,19 +446,19 @@ static void ParseClipInfo( const char *psz_clipinfo, char **ppsz_artist, char **
}
/* Put into args */
if
(
!
strcmp
(
psz_param
,
"artist name"
)
)
*
ppsz_artist
=
decode_URI
_duplicate
(
psz_value
);
*
ppsz_artist
=
vlc_uri_decode
_duplicate
(
psz_value
);
else
if
(
!
strcmp
(
psz_param
,
"title"
)
)
*
ppsz_title
=
decode_URI
_duplicate
(
psz_value
);
*
ppsz_title
=
vlc_uri_decode
_duplicate
(
psz_value
);
else
if
(
!
strcmp
(
psz_param
,
"album name"
)
)
*
ppsz_album
=
decode_URI
_duplicate
(
psz_value
);
*
ppsz_album
=
vlc_uri_decode
_duplicate
(
psz_value
);
else
if
(
!
strcmp
(
psz_param
,
"genre"
)
)
*
ppsz_genre
=
decode_URI
_duplicate
(
psz_value
);
*
ppsz_genre
=
vlc_uri_decode
_duplicate
(
psz_value
);
else
if
(
!
strcmp
(
psz_param
,
"year"
)
)
*
ppsz_year
=
decode_URI
_duplicate
(
psz_value
);
*
ppsz_year
=
vlc_uri_decode
_duplicate
(
psz_value
);
else
if
(
!
strcmp
(
psz_param
,
"cdnum"
)
)
*
ppsz_cdnum
=
decode_URI
_duplicate
(
psz_value
);
*
ppsz_cdnum
=
vlc_uri_decode
_duplicate
(
psz_value
);
else
if
(
!
strcmp
(
psz_param
,
"comments"
)
)
*
ppsz_comments
=
decode_URI
_duplicate
(
psz_value
);
*
ppsz_comments
=
vlc_uri_decode
_duplicate
(
psz_value
);
free
(
psz_suboption
);
psz_option_next
++
;
...
...
modules/gui/macosx/PLModel.m
View file @
6f15ed52
...
...
@@ -546,7 +546,7 @@ static int VolumeUpdated(vlc_object_t *p_this, const char *psz_var,
free
(
psz_value
);
}
else
if
([
o_identifier
isEqualToString
:
URI_COLUMN
])
{
psz_value
=
decode_URI
(
input_item_GetURI
(
p_input
));
psz_value
=
vlc_uri_decode
(
input_item_GetURI
(
p_input
));
o_value
=
toNSStr
(
psz_value
);
free
(
psz_value
);
...
...
modules/gui/macosx/VLCPlaylist.m
View file @
6f15ed52
...
...
@@ -777,7 +777,7 @@
if
(
!
[
self
isValidResumeItem
:
p_item
])
return
;
char
*
psz_url
=
decode_URI
(
input_item_GetURI
(
p_item
));
char
*
psz_url
=
vlc_uri_decode
(
input_item_GetURI
(
p_item
));
if
(
!
psz_url
)
return
;
NSString
*
url
=
toNSStr
(
psz_url
);
...
...
@@ -827,7 +827,7 @@
if
(
!
[
self
isValidResumeItem
:
p_item
])
return
;
char
*
psz_url
=
decode_URI
(
input_item_GetURI
(
p_item
));
char
*
psz_url
=
vlc_uri_decode
(
input_item_GetURI
(
p_item
));
if
(
!
psz_url
)
return
;
NSString
*
url
=
toNSStr
(
psz_url
);
...
...
modules/gui/macosx/VLCPlaylistInfo.m
View file @
6f15ed52
...
...
@@ -218,7 +218,7 @@
libvlc_MetaRequest
(
VLCIntf
->
p_libvlc
,
p_item
,
META_REQUEST_OPTION_NONE
);
/* fill uri info */
char
*
psz_url
=
decode_URI
(
input_item_GetURI
(
p_item
));
char
*
psz_url
=
vlc_uri_decode
(
input_item_GetURI
(
p_item
));
[
_uriTextField
setStringValue
:
toNSStr
(
psz_url
)];
free
(
psz_url
);
...
...
modules/gui/qt4/input_manager.cpp
View file @
6f15ed52
...
...
@@ -31,7 +31,7 @@
#include "recents.hpp"
#include <vlc_keys.h>
/* ACTION_ID */
#include <vlc_url.h>
/*
decode_URI
*/
#include <vlc_url.h>
/*
vlc_uri_decode
*/
#include <vlc_strings.h>
/* str_format_meta */
#include <vlc_aout.h>
/* audio_output_t */
...
...
@@ -525,7 +525,7 @@ void InputManager::UpdateName()
char
*
file
=
uri
?
strrchr
(
uri
,
'/'
)
:
NULL
;
if
(
file
!=
NULL
)
{
decode_URI
(
++
file
);
vlc_uri_decode
(
++
file
);
name
=
qfu
(
file
);
}
else
...
...
modules/gui/qt4/menus.cpp
View file @
6f15ed52
...
...
@@ -1585,7 +1585,7 @@ void VLCMenuBar::updateRecents( intf_thread_t *p_intf )
for
(
int
i
=
0
;
i
<
__MIN
(
l
.
count
(),
10
)
;
++
i
)
{
QString
mrl
=
l
.
at
(
i
);
char
*
psz
=
decode_URI
_duplicate
(
qtu
(
mrl
)
);
char
*
psz
=
vlc_uri_decode
_duplicate
(
qtu
(
mrl
)
);
QString
text
=
qfu
(
psz
);
text
.
replace
(
"&"
,
"&&"
);
...
...
modules/lua/libs/strings.c
View file @
6f15ed52
...
...
@@ -51,11 +51,10 @@ static int vlclua_decode_uri( lua_State *L )
for
(
i
=
1
;
i
<=
i_top
;
i
++
)
{
const
char
*
psz_cstring
=
luaL_checkstring
(
L
,
1
);
char
*
psz_string
=
strdup
(
psz_cstring
);
char
*
psz_string
=
vlc_uri_decode_duplicate
(
psz_cstring
);
lua_remove
(
L
,
1
);
/* remove elements to prevent being limited by
* the stack's size (this function will work with
* up to (stack size - 1) arguments */
decode_URI
(
psz_string
);
lua_pushstring
(
L
,
psz_string
);
free
(
psz_string
);
}
...
...
@@ -69,7 +68,7 @@ static int vlclua_encode_uri_component( lua_State *L )
for
(
i
=
1
;
i
<=
i_top
;
i
++
)
{
const
char
*
psz_cstring
=
luaL_checkstring
(
L
,
1
);
char
*
psz_string
=
encode_URI_component
(
psz_cstring
);
char
*
psz_string
=
vlc_uri_encode
(
psz_cstring
);
lua_remove
(
L
,
1
);
lua_pushstring
(
L
,
psz_string
);
free
(
psz_string
);
...
...
modules/misc/audioscrobbler.c
View file @
6f15ed52
...
...
@@ -168,7 +168,7 @@ static void ReadMetaData(intf_thread_t *p_this, input_thread_t *p_input)
#define ALLOC_ITEM_META(a, b) do { \
char *psz_meta = input_item_Get##b(p_item); \
if (psz_meta && *psz_meta) \
a =
encode_URI_component
(psz_meta); \
a =
vlc_uri_encode
(psz_meta); \
free(psz_meta); \
} while (0)
...
...
src/input/item.c
View file @
6f15ed52
...
...
@@ -330,7 +330,7 @@ void input_item_SetURI( input_item_t *p_i, const char *psz_uri )
/* Make the name more readable */
if
(
p_i
->
psz_name
)
{
decode_URI
(
p_i
->
psz_name
);
vlc_uri_decode
(
p_i
->
psz_name
);
EnsureUTF8
(
p_i
->
psz_name
);
}
}
...
...
src/libvlccore.sym
View file @
6f15ed52
...
...
@@ -87,8 +87,6 @@ decoder_SynchroNewPicture
decoder_SynchroRelease
decoder_SynchroReset
decoder_SynchroTrash
decode_URI
decode_URI_duplicate
demux_Delete
demux_PacketizerDestroy
demux_PacketizerNew
...
...
@@ -105,7 +103,6 @@ dialog_Question
dialog_Register
dialog_Unregister
dialog_VFatal
encode_URI_component
EndMD5
es_format_Clean
es_format_Copy
...
...
@@ -246,6 +243,9 @@ vlc_UrlParse
vlc_UrlClean
vlc_path2uri
vlc_uri2path
vlc_uri_decode
vlc_uri_decode_duplicate
vlc_uri_encode
mdate
module_config_free
module_config_get
...
...
src/test/url.c
View file @
6f15ed52
...
...
@@ -60,7 +60,7 @@ static void test (conv_t f, const char *in, const char *out)
static
inline
void
test_decode
(
const
char
*
in
,
const
char
*
out
)
{
test
(
decode_URI
_duplicate
,
in
,
out
);
test
(
vlc_uri_decode
_duplicate
,
in
,
out
);
}
static
inline
void
test_b64
(
const
char
*
in
,
const
char
*
out
)
...
...
src/text/url.c
View file @
6f15ed52
...
...
@@ -36,14 +36,10 @@
#include <vlc_fs.h>
#include <ctype.h>
/**
* Decodes an encoded URI component. See also decode_URI().
* \return decoded string allocated on the heap, or NULL on error.
*/
char
*
decode_URI_duplicate
(
const
char
*
str
)
char
*
vlc_uri_decode_duplicate
(
const
char
*
str
)
{
char
*
buf
=
strdup
(
str
);
if
(
decode_URI
(
buf
)
==
NULL
)
if
(
vlc_uri_decode
(
buf
)
==
NULL
)
{
free
(
buf
);
buf
=
NULL
;
...
...
@@ -51,20 +47,7 @@ char *decode_URI_duplicate (const char *str)
return
buf
;
}
/**
* Decodes an encoded URI component in place.
* <b>This function does NOT decode entire URIs.</b> Instead, it decodes one
* component at a time (e.g. host name, directory, file name).
* Decoded URIs do not exist in the real world (see RFC3986 §2.4).
* Complete URIs are always "encoded" (or they are syntaxically invalid).
*
* Note that URI encoding is different from Javascript escaping. Especially,
* white spaces and Unicode non-ASCII code points are encoded differently.
*
* \param str nul-terminated URI component to decode
* \return str on success, NULL if it was not properly encoded
*/
char
*
decode_URI
(
char
*
str
)
char
*
vlc_uri_decode
(
char
*
str
)
{
char
*
in
=
str
,
*
out
=
str
;
if
(
in
==
NULL
)
...
...
@@ -127,14 +110,7 @@ static char *encode_URI_bytes (const char *str, size_t *restrict lenp)
return
likely
(
out
!=
NULL
)
?
out
:
buf
;
}
/**
* Encodes a URI component (RFC3986 §2).
*
* @param str nul-terminated UTF-8 representation of the component.
* @note Obviously, a URI containing nul bytes cannot be passed.
* @return encoded string (must be free()'d), or NULL for ENOMEM.
*/
char
*
encode_URI_component
(
const
char
*
str
)
char
*
vlc_uri_encode
(
const
char
*
str
)
{
size_t
len
=
strlen
(
str
);
char
*
ret
=
encode_URI_bytes
(
str
,
&
len
);
...
...
@@ -265,7 +241,7 @@ char *vlc_uri2path (const char *url)
return
NULL
;
/* boom! */
/* Decode path */
decode_URI
(
path
);
vlc_uri_decode
(
path
);
if
(
schemelen
==
4
&&
!
strncasecmp
(
url
,
"file"
,
4
))
{
...
...
@@ -412,9 +388,9 @@ void vlc_UrlParse (vlc_url_t *restrict url, const char *str)
{
*
(
next
++
)
=
'\0'
;
url
->
psz_password
=
next
;
decode_URI
(
url
->
psz_password
);
vlc_uri_decode
(
url
->
psz_password
);
}
decode_URI
(
url
->
psz_username
);
vlc_uri_decode
(
url
->
psz_username
);
}
/* Host name */
...
...
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