diff options
author | Marco Nelissen <marcone@google.com> | 2014-03-07 02:25:59 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-03-07 02:25:59 +0000 |
commit | 908d31d763e46d56b1f437e90213ed14cd2b64e5 (patch) | |
tree | 4186504493d22806f2d918adec3b9502d3840f85 /media/libstagefright | |
parent | 28a51d04c0a25b424389b205c8de2bec66b76024 (diff) | |
parent | 8519b8a1298d80949edadce9c8f0963ef62cc3ff (diff) | |
download | frameworks_av-908d31d763e46d56b1f437e90213ed14cd2b64e5.zip frameworks_av-908d31d763e46d56b1f437e90213ed14cd2b64e5.tar.gz frameworks_av-908d31d763e46d56b1f437e90213ed14cd2b64e5.tar.bz2 |
am 8519b8a1: Merge "M3UParser: Skip query strings when looking for the last slash in a URL"
* commit '8519b8a1298d80949edadce9c8f0963ef62cc3ff':
M3UParser: Skip query strings when looking for the last slash in a URL
Diffstat (limited to 'media/libstagefright')
-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 dd248cb..292d1c4 100644 --- a/media/libstagefright/httplive/M3UParser.cpp +++ b/media/libstagefright/httplive/M3UParser.cpp @@ -416,22 +416,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 - 1 = end; 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()); |