]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
webui: import redirected css through @import, fixes #3738
authorJaroslav Kysela <perex@perex.cz>
Thu, 21 Apr 2016 11:39:36 +0000 (13:39 +0200)
committerJaroslav Kysela <perex@perex.cz>
Thu, 21 Apr 2016 11:39:36 +0000 (13:39 +0200)
src/http.c
src/http.h
src/webui/webui.c

index 243c70774a9f3348ad61613252b9b6fe078a5ca1..60c92e8838fe1ee9a6ee8c879072e832f174207e 100644 (file)
@@ -635,7 +635,7 @@ http_redirect(http_connection_t *hc, const char *location,
     loc = htsbuf_to_string(&hq);
     htsbuf_queue_flush(&hq);
   } else if (!external && tvheadend_webroot && location[0] == '/') {
-    loc = malloc(strlen(location) + strlen(tvheadend_webroot) + 1);
+    loc = alloca(strlen(location) + strlen(tvheadend_webroot) + 1);
     strcpy((char *)loc, tvheadend_webroot);
     strcat((char *)loc, location);
   }
@@ -650,8 +650,28 @@ http_redirect(http_connection_t *hc, const char *location,
                 loc, loc);
 
   http_send_reply(hc, HTTP_STATUS_FOUND, "text/html", NULL, loc, 0);
-  if (loc != location)
-    free((void *)loc);
+}
+
+
+/**
+ * Send an CSS @import
+ */
+void
+http_css_import(http_connection_t *hc, const char *location)
+{
+  const char *loc = location;
+
+  htsbuf_queue_flush(&hc->hc_reply);
+
+  if (tvheadend_webroot && location[0] == '/') {
+    loc = alloca(strlen(location) + strlen(tvheadend_webroot) + 1);
+    strcpy((char *)loc, tvheadend_webroot);
+    strcat((char *)loc, location);
+  }
+
+  htsbuf_qprintf(&hc->hc_reply, "@import url('%s');\r\n", loc);
+
+  http_send_reply(hc, HTTP_STATUS_OK, "text/css", NULL, loc, 0);
 }
 
 /**
index 2a8d9b78ce3448e524dda6970733fccab7c4066b..b929daa6c7596670089f4b842bc22f7f536417d0 100644 (file)
@@ -203,6 +203,8 @@ void http_output_content(http_connection_t *hc, const char *content);
 void http_redirect(http_connection_t *hc, const char *location,
                    struct http_arg_list *req_args, int external);
 
+void http_css_import(http_connection_t *hc, const char *location);
+
 void http_send_header(http_connection_t *hc, int rc, const char *content, 
                      int64_t contentlen, const char *encoding,
                      const char *location, int maxage, const char *range,
index cb0918ee6ad29b1bd2370744fc117bfc77ae3b4f..8e3edee7a3287987e844f45909875f1905bd816b 100644 (file)
@@ -1794,7 +1794,7 @@ http_redir(http_connection_t *hc, const char *remain, void *opaque)
         snprintf(buf, sizeof(buf), "src/webui/static/tvh.%s.css.gz", theme);
         if (!http_file_test(buf)) {
           snprintf(buf, sizeof(buf), "/static/tvh.%s.css.gz", theme);
-          http_redirect(hc, buf, NULL, 0);
+          http_css_import(hc, buf);
           return 0;
         }
       }
@@ -1806,7 +1806,7 @@ http_redir(http_connection_t *hc, const char *remain, void *opaque)
         snprintf(buf, sizeof(buf), "src/webui/static/extjs/resources/css/xtheme-%s.css", theme);
         if (!http_file_test(buf)) {
           snprintf(buf, sizeof(buf), "/static/extjs/resources/css/xtheme-%s.css", theme);
-          http_redirect(hc, buf, NULL, 0);
+          http_css_import(hc, buf);
           return 0;
         }
       }