;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016 ng0 ;;; Copyright © 2016 Sou Bunnbu ;;; Copyright © 2017 Oleg Pykhalov ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . (define-module (gnu services version-control) #:use-module (gnu services) #:use-module (gnu services base) #:use-module (gnu services shepherd) #:use-module (gnu services web) #:use-module (gnu system shadow) #:use-module (gnu packages version-control) #:use-module (gnu packages admin) #:use-module (guix records) #:use-module (guix gexp) #:use-module (guix store) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:use-module (ice-9 match) #:export (git-daemon-
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'content')
-rw-r--r--content/main.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/content/main.js b/content/main.js
index 4fe6d43..b2cc9ed 100644
--- a/content/main.js
+++ b/content/main.js
@@ -180,6 +180,26 @@ function sanitize_meta(meta, policy)
meta.content = sanitize_csp_header({value}, policy).value;
}
+function sanitize_script(script)
+{
+ script.hachette_blocked_type = script.type;
+ script.type = "text/plain";
+}
+
+/*
+ * Executed after script has been connected to the DOM, when it is no longer
+ * eligible for being executed by the browser
+ */
+function desanitize_script(script, policy)
+{
+ script.setAttribute("type", script.hachette_blocked_type);
+
+ if (script.hachette_blocked_type === undefined)
+ script.removeAttribute("type");
+
+ delete script.hachette_blocked_type;
+}
+
function apply_hachette_csp_rules(doc, policy)
{
const meta = doc.createElement("meta");
@@ -220,7 +240,13 @@ async function sanitize_document(doc, policy)
for (const meta of old_html.querySelectorAll("head meta"))
sanitize_meta(meta, policy);
+ for (const script of old_html.querySelectorAll("script"))
+ sanitize_script(script, policy);
+
new_html.replaceWith(old_html);
+
+ for (const script of old_html.querySelectorAll("script"))
+ desanitize_script(script, policy);
}
if (!is_privileged_url(document.URL)) {
(key/value ("css" css) ("logo" logo) ("robots" (cgit-configuration-robots-string robots)) ("virtual-root" virtual-root) ("scan-path" repository-directory))))))) (define %cgit-configuration-nginx (list (nginx-server-configuration (root cgit) (locations (list (nginx-location-configuration (uri "@cgit") (body '("fastcgi_param SCRIPT_FILENAME $document_root/lib/cgit/cgit.cgi;" "fastcgi_param PATH_INFO $uri;" "fastcgi_param QUERY_STRING $args;" "fastcgi_param HTTP_HOST $server_name;" "fastcgi_pass 127.0.0.1:9000;"))))) (try-files (list "$uri" "@cgit")) (https-port #f) (ssl-certificate #f) (ssl-certificate-key #f)))) (define-record-type* cgit-configuration make-cgit-configuration cgit-configuration? (config-file cgit-configuration-config-file (default (cgit-configuration-file))) (package cgit-configuration-package (default cgit)) (nginx cgit-configuration-nginx (default %cgit-configuration-nginx))) (define (cgit-activation config) ;; Cgit compiled with default configuration path #~(begin (use-modules (guix build utils)) (mkdir-p "/var/cache/cgit") (copy-file #$(cgit-configuration-config-file config) "/etc/cgitrc"))) (define (cgit-configuration-nginx-config config) (cgit-configuration-nginx config)) (define cgit-service-type (service-type (name 'cgit) (extensions (list (service-extension activation-service-type cgit-activation) (service-extension nginx-service-type cgit-configuration-nginx-config))) (default-value (cgit-configuration))))