mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-24 03:49:14 -05:00
[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:
parent
947d3a0719
commit
c1db4d914f
@ -319,7 +319,7 @@ http_stream_setup(char **stream, const char *url)
|
|||||||
line = pos;
|
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);
|
DPRINTF(E_DBG, L_HTTP, "Found internet playlist stream (line %d): %s\n", n, line);
|
||||||
|
|
||||||
|
@ -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);
|
safe_json_add_string(item, "uri", queue_item->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (queue_item->artwork_url
|
if (queue_item->artwork_url && net_is_http_or_https(queue_item->artwork_url))
|
||||||
&& (strncmp(queue_item->artwork_url, "http://", strlen("http://")) == 0
|
|
||||||
|| strncmp(queue_item->artwork_url, "https://", strlen("https://")) == 0))
|
|
||||||
{
|
{
|
||||||
// The queue item contains a valid http url for an artwork image, there is no need
|
// 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.
|
// for the client to request the image through the server artwork handler.
|
||||||
|
@ -1775,7 +1775,7 @@ queue_item_stream_add(const char *path, int position, char reshuffle, uint32_t i
|
|||||||
static int
|
static int
|
||||||
queue_item_add(const char *uri, int position, char reshuffle, uint32_t item_id, int *count, int *new_item_id)
|
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);
|
queue_item_stream_add(uri, position, reshuffle, item_id, count, new_item_id);
|
||||||
return LIBRARY_OK;
|
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);
|
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);
|
path = (virtual_path + 1);
|
||||||
|
|
||||||
|
@ -485,7 +485,7 @@ scan_playlist(const char *file, time_t mtime, int dir_id)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// URLs and playlists will be added to library, tracks should already be there
|
// 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);
|
ret = process_url(pl_id, path, &mfi);
|
||||||
else if (playlist_type(path) != PLAYLIST_UNKNOWN)
|
else if (playlist_type(path) != PLAYLIST_UNKNOWN)
|
||||||
ret = process_nested_playlist(pl_id, path);
|
ret = process_nested_playlist(pl_id, path);
|
||||||
|
@ -622,7 +622,7 @@ rss_add(const char *path)
|
|||||||
{
|
{
|
||||||
int ret;
|
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);
|
DPRINTF(E_SPAM, L_LIB, "Invalid RSS path '%s'\n", path);
|
||||||
return LIBRARY_PATH_INVALID;
|
return LIBRARY_PATH_INVALID;
|
||||||
|
@ -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 -------------------- */
|
/* ----------------------- Conversion/hashing/sanitizers -------------------- */
|
||||||
|
|
||||||
|
@ -54,6 +54,9 @@ net_bind(short unsigned *port, int type, const char *log_service_name);
|
|||||||
int
|
int
|
||||||
net_evhttp_bind(struct evhttp *evhttp, short unsigned port, const char *log_service_name);
|
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 -------------------- */
|
/* ----------------------- Conversion/hashing/sanitizers -------------------- */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user