]> 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:37:22 +0000 (18:37 +0200)
src/channels.c
src/http.c
src/http.h
src/tvheadend.h
src/utils.c

index ece0068564e50770832450dd6eba65eefb09e3ff..b80ce5ede8c6fc3f500687a41a4543d0fedd30f2 100644 (file)
@@ -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;
 }
 
index 2d6c3c798092ec4671c9b45b3c2fb673a8580094..646ec9324f2182999070bf271176c0138a9c5ae6 100644 (file)
@@ -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
  */
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 da90eedd56ae5e12c364bdd7f5651cc234ab1e0d..c05f46215b572c58b5b37e45004000d6ce445d3c 100644 (file)
@@ -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);
 
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;
+}
+
 /*
  *
  */