mirror of https://git.ffmpeg.org/ffmpeg.git
Handle the following type of relative URL correctly:
http://a/b + //c/d = http://c/d http://a/b?c + ?d = http://a/b?d http://a/b?c/d + /e = http://a/e Updated with feedback from Clément Bœsch Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
f75c5f07a9
commit
4b80a619b7
|
@ -4467,17 +4467,23 @@ int ff_find_stream_index(AVFormatContext *s, int id)
|
||||||
void ff_make_absolute_url(char *buf, int size, const char *base,
|
void ff_make_absolute_url(char *buf, int size, const char *base,
|
||||||
const char *rel)
|
const char *rel)
|
||||||
{
|
{
|
||||||
char *sep;
|
char *sep, *path_query;
|
||||||
/* Absolute path, relative to the current server */
|
/* Absolute path, relative to the current server */
|
||||||
if (base && strstr(base, "://") && rel[0] == '/') {
|
if (base && strstr(base, "://") && rel[0] == '/') {
|
||||||
if (base != buf)
|
if (base != buf)
|
||||||
av_strlcpy(buf, base, size);
|
av_strlcpy(buf, base, size);
|
||||||
sep = strstr(buf, "://");
|
sep = strstr(buf, "://");
|
||||||
if (sep) {
|
if (sep) {
|
||||||
sep += 3;
|
/* Take scheme from base url */
|
||||||
sep = strchr(sep, '/');
|
if (rel[1] == '/')
|
||||||
if (sep)
|
sep[1] = '\0';
|
||||||
*sep = '\0';
|
else {
|
||||||
|
/* Take scheme and host from base url */
|
||||||
|
sep += 3;
|
||||||
|
sep = strchr(sep, '/');
|
||||||
|
if (sep)
|
||||||
|
*sep = '\0';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
av_strlcat(buf, rel, size);
|
av_strlcat(buf, rel, size);
|
||||||
return;
|
return;
|
||||||
|
@ -4489,6 +4495,18 @@ void ff_make_absolute_url(char *buf, int size, const char *base,
|
||||||
}
|
}
|
||||||
if (base != buf)
|
if (base != buf)
|
||||||
av_strlcpy(buf, base, size);
|
av_strlcpy(buf, base, size);
|
||||||
|
|
||||||
|
/* Strip off any query string from base */
|
||||||
|
path_query = strchr(buf, '?');
|
||||||
|
if (path_query != NULL)
|
||||||
|
*path_query = '\0';
|
||||||
|
|
||||||
|
/* Is relative path just a new query part? */
|
||||||
|
if (rel[0] == '?') {
|
||||||
|
av_strlcat(buf, rel, size);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Remove the file name from the base url */
|
/* Remove the file name from the base url */
|
||||||
sep = strrchr(buf, '/');
|
sep = strrchr(buf, '/');
|
||||||
if (sep)
|
if (sep)
|
||||||
|
|
Loading…
Reference in New Issue