From: Jaroslav Kysela Date: Fri, 16 Jun 2017 16:31:34 +0000 (+0200) Subject: channels: icon file:// URLs must be deescaped X-Git-Tag: v4.2.3~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7eb1d75299838f50d6e3ca9a856601d2ab7512d4;p=thirdparty%2Ftvheadend.git channels: icon file:// URLs must be deescaped --- diff --git a/src/channels.c b/src/channels.c index ece006856..b80ce5ede 100644 --- a/src/channels.c +++ b/src/channels.c @@ -779,8 +779,11 @@ svcnamepicons(const char *svcname) static int check_file( const char *url ) { - if (url && !strncmp(url, "file://", 7)) - return access(url + 7, R_OK) == 0; + if (url && !strncmp(url, "file://", 7)) { + char *s = tvh_strdupa(url + 7); + http_deescape(s); + return access(s, R_OK) == 0; + } return 1; } diff --git a/src/http.c b/src/http.c index 2d6c3c798..646ec9324 100644 --- a/src/http.c +++ b/src/http.c @@ -1363,60 +1363,6 @@ http_path_add(const char *path, void *opaque, http_callback_t *callback, return http_path_add_modify(path, opaque, callback, accessmask, NULL); } -/** - * De-escape HTTP URL - */ -void -http_deescape(char *s) -{ - char v, *d = s; - - while(*s) { - if(*s == '+') { - *d++ = ' '; - s++; - } else if(*s == '%') { - s++; - switch(*s) { - case '0' ... '9': - v = (*s - '0') << 4; - break; - case 'a' ... 'f': - v = (*s - 'a' + 10) << 4; - break; - case 'A' ... 'F': - v = (*s - 'A' + 10) << 4; - break; - default: - *d = 0; - return; - } - s++; - switch(*s) { - case '0' ... '9': - v |= (*s - '0'); - break; - case 'a' ... 'f': - v |= (*s - 'a' + 10); - break; - case 'A' ... 'F': - v |= (*s - 'A' + 10); - break; - default: - *d = 0; - return; - } - s++; - - *d++ = v; - } else { - *d++ = *s++; - } - } - *d = 0; -} - - /** * Parse arguments of a HTTP GET url, not perfect, but works for us */ diff --git a/src/http.h b/src/http.h index 67749f8ae..36c8e97bf 100644 --- a/src/http.h +++ b/src/http.h @@ -246,8 +246,6 @@ int http_access_verify(http_connection_t *hc, int mask); int http_access_verify_channel(http_connection_t *hc, int mask, struct channel *ch); -void http_deescape(char *s); - void http_parse_args(http_arg_list_t *list, char *args); char *http_get_hostpath(http_connection_t *hc); diff --git a/src/tvheadend.h b/src/tvheadend.h index da90eedd5..c05f46215 100644 --- a/src/tvheadend.h +++ b/src/tvheadend.h @@ -828,6 +828,7 @@ int tvh_gzip_deflate_fd_header ( int fd, const uint8_t *data, size_t orig, /* URL decoding */ char to_hex(char code); char *url_encode(const char *str); +void http_deescape(char *str); int mpegts_word_count(const uint8_t *tsb, int len, uint32_t mask); diff --git a/src/utils.c b/src/utils.c index 6ec705049..c34762cf4 100644 --- a/src/utils.c +++ b/src/utils.c @@ -622,6 +622,59 @@ char *url_encode(const char *str) return buf; } +/** + * De-escape HTTP URL + */ +void +http_deescape(char *s) +{ + char v, *d = s; + + while(*s) { + if(*s == '+') { + *d++ = ' '; + s++; + } else if(*s == '%') { + s++; + switch(*s) { + case '0' ... '9': + v = (*s - '0') << 4; + break; + case 'a' ... 'f': + v = (*s - 'a' + 10) << 4; + break; + case 'A' ... 'F': + v = (*s - 'A' + 10) << 4; + break; + default: + *d = 0; + return; + } + s++; + switch(*s) { + case '0' ... '9': + v |= (*s - '0'); + break; + case 'a' ... 'f': + v |= (*s - 'a' + 10); + break; + case 'A' ... 'F': + v |= (*s - 'A' + 10); + break; + default: + *d = 0; + return; + } + s++; + + *d++ = v; + } else { + *d++ = *s++; + } + } + *d = 0; +} + /* * */