From f216a1996ab3b2e4b3f7d82e637ae4325d660cab Mon Sep 17 00:00:00 2001 From: blankie Date: Tue, 29 Nov 2022 20:28:28 +0700 Subject: [PATCH] Stop redirecting pages if there's a redirect=no parameter --- src/page-wiki.rkt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/page-wiki.rkt b/src/page-wiki.rkt index 6f22ad8..e41b093 100644 --- a/src/page-wiki.rkt +++ b/src/page-wiki.rkt @@ -94,10 +94,14 @@ #:head-data head-data #:siteinfo siteinfo)) (define redirect-msg ((query-selector (attribute-selector 'class "redirectMsg") body))) + (define redirect-query-parameter (dict-ref (url-query (request-uri req)) 'redirect "yes")) (define headers (build-headers always-headers - (when redirect-msg + ; redirect-query-parameter: only the string "no" is significant: + ; https://github.com/Wikia/app/blob/fe60579a53f16816d65dad1644363160a63206a6/includes/Wiki.php#L367 + (when (and redirect-msg + (not (equal? redirect-query-parameter "no"))) (let* ([dest (get-attribute 'href (bits->attributes ((query-selector (λ (t a c) (eq? t 'a)) redirect-msg))))] [value (bytes-append #"0;url=" (string->bytes/utf-8 dest))]) (header #"Refresh" value)))))