1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

applehttp: Add comments to make_absolute_url

Originally committed as revision 25319 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Martin Storsjö 2010-10-02 21:59:16 +00:00
parent 9d229ef9e6
commit ae8c28db87

View File

@ -90,18 +90,21 @@ static void make_absolute_url(char *buf, int size, const char *base,
const char *rel) const char *rel)
{ {
char *sep; char *sep;
/* If rel actually is an absolute url, just copy it */
if (!base || strstr(rel, "://") || rel[0] == '/') { if (!base || strstr(rel, "://") || rel[0] == '/') {
av_strlcpy(buf, rel, size); av_strlcpy(buf, rel, size);
return; return;
} }
if (base != buf) if (base != buf)
av_strlcpy(buf, base, size); av_strlcpy(buf, base, size);
/* Remove the file name from the base url */
sep = strrchr(buf, '/'); sep = strrchr(buf, '/');
if (sep) if (sep)
sep[1] = '\0'; sep[1] = '\0';
else else
buf[0] = '\0'; buf[0] = '\0';
while (av_strstart(rel, "../", NULL) && sep) { while (av_strstart(rel, "../", NULL) && sep) {
/* Remove the path delimiter at the end */
sep[0] = '\0'; sep[0] = '\0';
sep = strrchr(buf, '/'); sep = strrchr(buf, '/');
/* If the next directory name to pop off is "..", break here */ /* If the next directory name to pop off is "..", break here */
@ -110,6 +113,7 @@ static void make_absolute_url(char *buf, int size, const char *base,
av_strlcat(buf, "/", size); av_strlcat(buf, "/", size);
break; break;
} }
/* Cut off the directory name */
if (sep) if (sep)
sep[1] = '\0'; sep[1] = '\0';
else else