diff options
author | Martin Storsjo <martin@martin.st> | 2013-11-22 17:05:05 +0200 |
---|---|---|
committer | Lajos Molnar <lajos@google.com> | 2014-03-06 18:11:27 -0800 |
commit | 75d03185ac7be95c700f3f375080989e5de03ef6 (patch) | |
tree | 5bb078ad258d93dbb3e024e575fafb142b229ffa | |
parent | e2492dc46f5476e3abc617ee21d74f44198591dd (diff) | |
download | frameworks_av-75d03185ac7be95c700f3f375080989e5de03ef6.zip frameworks_av-75d03185ac7be95c700f3f375080989e5de03ef6.tar.gz frameworks_av-75d03185ac7be95c700f3f375080989e5de03ef6.tar.bz2 |
M3UParser: Skip query strings when looking for the last slash in a URL
Bug: 13174301
Change-Id: I72d3a5e11fef9bbd75b291bc490c9cab1dce58da
-rw-r--r-- | media/libstagefright/httplive/M3UParser.cpp | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/media/libstagefright/httplive/M3UParser.cpp b/media/libstagefright/httplive/M3UParser.cpp index a9184b5..8f530ee 100644 --- a/media/libstagefright/httplive/M3UParser.cpp +++ b/media/libstagefright/httplive/M3UParser.cpp @@ -423,22 +423,32 @@ static bool MakeURL(const char *baseURL, const char *url, AString *out) { } else { // URL is a relative path - size_t n = strlen(baseURL); - if (baseURL[n - 1] == '/') { - out->setTo(baseURL); - out->append(url); + // Check for a possible query string + const char *qsPos = strchr(baseURL, '?'); + size_t end; + if (qsPos != NULL) { + end = qsPos - baseURL; } else { - const char *slashPos = strrchr(baseURL, '/'); - - if (slashPos > &baseURL[6]) { - out->setTo(baseURL, slashPos - baseURL); - } else { - out->setTo(baseURL); + end = strlen(baseURL); + } + // Check for the last slash before a potential query string + for (ssize_t pos = end - 1; pos >= 0; pos--) { + if (baseURL[pos] == '/') { + end = pos; + break; } + } - out->append("/"); - out->append(url); + // Check whether the found slash actually is part of the path + // and not part of the "http://". + if (end > 6) { + out->setTo(baseURL, end); + } else { + out->setTo(baseURL); } + + out->append("/"); + out->append(url); } ALOGV("base:'%s', url:'%s' => '%s'", baseURL, url, out->c_str()); |