[http] Temporary fix for bug in commit 8f899f2

See 8f899f2051 (commitcomment-26433079)
This commit is contained in:
ejurgensen 2018-01-02 21:20:28 +01:00
parent f71028b25d
commit 8d043dd9e9

View File

@ -41,6 +41,7 @@
#endif #endif
#include "http.h" #include "http.h"
#include "httpd.h"
#include "logger.h" #include "logger.h"
#include "misc.h" #include "misc.h"
@ -444,40 +445,38 @@ int
http_stream_setup(char **stream, const char *url) http_stream_setup(char **stream, const char *url)
{ {
struct http_client_ctx ctx; struct http_client_ctx ctx;
struct httpd_uri_parsed *parsed;
struct evbuffer *evbuf; struct evbuffer *evbuf;
const char *ext; const char *ext;
char *line; char *line;
char *pos;
int ret; int ret;
int n; int n;
const char *pos;
char ch;
int pl_format; int pl_format;
bool in_playlist; bool in_playlist;
*stream = NULL; *stream = NULL;
pl_format = PLAYLIST_UNK;
// Find last dot before query or fragment, parsed = httpd_uri_parse(url);
// e.g., http://yp.shoutcast.com/sbin/tunein-station.pls?id=99179772#Air Jazz if (!parsed)
pos = url;
ext = NULL;
while ((ch = *pos) != '\0')
{ {
if (ch == '?' || ch == '#') DPRINTF(E_LOG, L_HTTP, "Couldn't parse internet playlist: '%s'\n", url);
break; return -1;
if (ch == '.')
ext = pos;
++pos;
} }
if (ext) // parsed->path does not include query or fragment, so should work with any url's
// e.g. http://yp.shoutcast.com/sbin/tunein-station.pls?id=99179772#Air Jazz
pl_format = PLAYLIST_UNK;
if (parsed->path && (ext = strrchr(parsed->path, '.')))
{ {
if (strncasecmp(ext, ".m3u", 4) == 0) if (strcasecmp(ext, ".m3u") == 0)
pl_format = PLAYLIST_M3U; pl_format = PLAYLIST_M3U;
else if (strncasecmp(ext, ".pls", 4) == 0) else if (strcasecmp(ext, ".pls") == 0)
pl_format = PLAYLIST_PLS; pl_format = PLAYLIST_PLS;
} }
httpd_uri_free(parsed);
if (pl_format==PLAYLIST_UNK) if (pl_format==PLAYLIST_UNK)
{ {
*stream = strdup(url); *stream = strdup(url);
@ -552,7 +551,7 @@ http_stream_setup(char **stream, const char *url)
// allocate the value part and proceed as with m3u // allocate the value part and proceed as with m3u
pos = strdup(pos); pos = strdup(pos);
free(line); free(line);
line = (char *) pos; line = pos;
} }
if (strncasecmp(line, "http://", strlen("http://")) == 0) if (strncasecmp(line, "http://", strlen("http://")) == 0)