]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
channels: icon file:// URLs must be deescaped
authorJaroslav Kysela <perex@perex.cz>
Fri, 16 Jun 2017 16:31:34 +0000 (18:31 +0200)
committerJaroslav Kysela <perex@perex.cz>
Fri, 16 Jun 2017 16:41:07 +0000 (18:41 +0200)
src/channels.c
src/http.c
src/http.h
src/tvheadend.h
src/utils.c

index 3f76b9231643bf5984f9e623f8ba7c574b76e74f..264a9735759d6dfc22158061125af85deadf93a3 100644 (file)
@@ -792,8 +792,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;
 }
 
index 4882410a753b4d109286308b73718247b40ccfc4..9a4bad7c3d4fd0309b435a1280f4926ee7800406 100644 (file)
@@ -1364,60 +1364,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
  */
index 67749f8aeb854ac355b30064ad876014ed7288cf..36c8e97bfd1c8c4285a6de8082a91f709a8cbe3d 100644 (file)
@@ -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);
index 49954c393ada4e3da9b6fdbb9838c1a83c889253..175b1e05cb942cf96646f0748388e52ce780ab6e 100644 (file)
@@ -830,6 +830,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);
 
index 6ec7050492aaa9b3aa7b43b999387a1355cb654b..c34762cf42998423313190bfc5117c751354cc94 100644 (file)
@@ -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;
+}
+
 /*
  *
  */