~technomancy/fennel-lang.org

f2185dc0bac543d8069cedae6079f10b2d809c0c — Phil Hagelberg 8 months ago e56e4a1
Broaden page title pattern a bit.
2 files changed, 7 insertions(+), 4 deletions(-)

M wiki/.htaccess
M wiki/index.fnl
M wiki/.htaccess => wiki/.htaccess +1 -1
@@ 5,6 5,6 @@ Header set Strict-Transport-Security "max-age=31536000"
Header set X-Frame-Options "DENY"
Header set X-XSS-Protection "1; mode=block"

RewriteRule "^([A-Za-z]*)$" "/index.cgi?page=$1"
RewriteRule "^([-A-Za-z/]*)$" "/index.cgi?page=$1"

ErrorDocument 404 /404.html

M wiki/index.fnl => wiki/index.fnl +6 -3
@@ 3,9 3,12 @@
;; wikis. for now we can just proxy the content from github and allow edits
;; to be done over git+SSH.

;; TODO:
;; * syntax highlighting for code snippets
;; * search

(local head
       "<!DOCTYPE html>
<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"\" xml:lang=\"\">
<head>
  <meta charset=\"utf-8\" />
  <link rel=\"stylesheet\" href=\"https://fennel-lang.org/fennel.css\"></link>


@@ 25,7 28,7 @@
(fn url-for [page]
  (let [url (.. "https://github.com/bakpakin/Fennel/wiki/" page)]
    ;; we REALLY don't want to let arbitrary input thru here when we shell out
    (assert (not (page:match "[ %.]")) "Illegal page; can't shell out to curl!")
    (assert (not (page:match "[ $%(%)%.;&|]")) "Illegal page; can't shell out to curl!")
    url))

(fn get-body [page]


@@ 35,7 38,7 @@
    body))

(fn query-string []
  (or (: (or (os.getenv "QUERY_STRING") "") :match "page=([-a-zA-Z]+)") ""))
  (or (: (or (os.getenv "QUERY_STRING") "") :match "page=([-a-zA-Z/]+)") ""))

(let [page (match (query-string) "" "Home" p p)
      body (get-body (query-string))