[http] Also allow remote playlists to have https streams (fixes #1251)

Fix it by adding net_is_http_or_https() utility function in misc.h and make
sure it used whenever a http protocol check is made.
This commit is contained in:
ejurgensen 2021-05-19 22:53:25 +02:00
parent 947d3a0719
commit c1db4d914f
7 changed files with 14 additions and 8 deletions

View File

@ -319,7 +319,7 @@ http_stream_setup(char **stream, const char *url)
line = pos;
}
if (strncasecmp(line, "http://", strlen("http://")) == 0)
if (net_is_http_or_https(line))
{
DPRINTF(E_DBG, L_HTTP, "Found internet playlist stream (line %d): %s\n", n, line);

View File

@ -2184,9 +2184,7 @@ queue_item_to_json(struct db_queue_item *queue_item, char shuffle)
safe_json_add_string(item, "uri", queue_item->path);
}
if (queue_item->artwork_url
&& (strncmp(queue_item->artwork_url, "http://", strlen("http://")) == 0
|| strncmp(queue_item->artwork_url, "https://", strlen("https://")) == 0))
if (queue_item->artwork_url && net_is_http_or_https(queue_item->artwork_url))
{
// The queue item contains a valid http url for an artwork image, there is no need
// for the client to request the image through the server artwork handler.

View File

@ -1775,7 +1775,7 @@ queue_item_stream_add(const char *path, int position, char reshuffle, uint32_t i
static int
queue_item_add(const char *uri, int position, char reshuffle, uint32_t item_id, int *count, int *new_item_id)
{
if (strncasecmp(uri, "http://", strlen("http://")) == 0 || strncasecmp(uri, "https://", strlen("https://")) == 0)
if (net_is_http_or_https(uri))
{
queue_item_stream_add(uri, position, reshuffle, item_id, count, new_item_id);
return LIBRARY_OK;
@ -1941,7 +1941,7 @@ playlist_add_files(FILE *fp, int pl_id, const char *virtual_path)
DPRINTF(E_DBG, L_SCAN, "Item '%s' added to playlist (id = %d)\n", dbmfi.path, pl_id);
}
}
else if (strncasecmp(virtual_path, "/http://", strlen("/http://")) == 0 || strncasecmp(virtual_path, "/https://", strlen("/https://")) == 0)
else if (virtual_path[0] != '\0' && net_is_http_or_https(virtual_path + 1))
{
path = (virtual_path + 1);

View File

@ -485,7 +485,7 @@ scan_playlist(const char *file, time_t mtime, int dir_id)
continue;
// URLs and playlists will be added to library, tracks should already be there
if (strncasecmp(path, "http://", 7) == 0 || strncasecmp(path, "https://", 8) == 0)
if (net_is_http_or_https(path))
ret = process_url(pl_id, path, &mfi);
else if (playlist_type(path) != PLAYLIST_UNKNOWN)
ret = process_nested_playlist(pl_id, path);

View File

@ -622,7 +622,7 @@ rss_add(const char *path)
{
int ret;
if (strncmp(path, "http://", 7) != 0 && strncmp(path, "https://", 8) != 0)
if (!net_is_http_or_https(path))
{
DPRINTF(E_SPAM, L_LIB, "Invalid RSS path '%s'\n", path);
return LIBRARY_PATH_INVALID;

View File

@ -363,6 +363,11 @@ net_evhttp_bind(struct evhttp *evhttp, short unsigned port, const char *log_serv
}
*/
bool
net_is_http_or_https(const char *url)
{
return (strncasecmp(url, "http://", strlen("http://")) == 0 || strncasecmp(url, "https://", strlen("https://")) == 0);
}
/* ----------------------- Conversion/hashing/sanitizers -------------------- */

View File

@ -54,6 +54,9 @@ net_bind(short unsigned *port, int type, const char *log_service_name);
int
net_evhttp_bind(struct evhttp *evhttp, short unsigned port, const char *log_service_name);
// Just checks if the protocol is http or https
bool
net_is_http_or_https(const char *url);
/* ----------------------- Conversion/hashing/sanitizers -------------------- */