1
0
Fork 0

Improve security question. Fix reindexing.

This commit is contained in:
Andy Wingo 2017-03-02 15:28:55 +00:00
parent e700e4af7a
commit 01ca951b76
4 changed files with 23 additions and 16 deletions

View file

@ -30,6 +30,7 @@
#:use-module (tekuti util)
#:use-module (tekuti filters)
#:use-module (tekuti post)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-19)
#:use-module (sxml transform)
@ -95,10 +96,12 @@
`(p "Bad URL. (Only http and https are allowed.)")))
(define (bad-number? x)
(if (string->number x)
#f
'(p "Bad number. Give me something that Scheme's "
(tt "string->number") " will like.")))
(match (string->number x)
(#f '(p "Bad number. Give me something that Scheme's "
(tt "string->number") " will like."))
(n (if (and (real? n) (<= 34 n 42))
#f
'(p "Number not between 34 and 42.")))))
(define *new-comment-spec*
`(("author" ,(lambda (x) #f))

View file

@ -171,7 +171,7 @@
(let ((s (string-trim-both (call-with-input-file rev read-line))))
(and (= (string-length s) 40)
s)))
(git "rev-parse" rev)))
(string-trim-both (git "rev-parse" rev))))
(define (git-rev-list rev n)
(let lp ((lines (string-split

View file

@ -25,6 +25,7 @@
;;; Code:
(define-module (tekuti index)
#:use-module (ice-9 match)
#:use-module ((srfi srfi-1) #:select (fold))
#:use-module (system repl error-handling)
#:use-module (tekuti util)
@ -80,16 +81,19 @@
new))
(define (read-index)
(let* ((ref (false-if-git-error (git-rev-parse "refs/heads/index")))
(dents (if ref (git-ls-tree ref #f) '())))
(acons 'index ref
(and (and-map (lambda (spec)
(assoc (symbol->string (car spec)) dents))
index-specs)
(map (lambda (dent)
(cons (string->symbol (car dent))
(blob->index (car dent) (cadr dent))))
dents)))))
(match (false-if-git-error (git-rev-parse "refs/heads/index"))
(#f (maybe-reindex '()))
(ref
(let ((dents (git-ls-tree ref #f)))
(if (and-map (lambda (spec)
(assoc (symbol->string (car spec)) dents))
index-specs)
(acons 'index ref
(map (lambda (dent)
(cons (string->symbol (car dent))
(blob->index (car dent) (cadr dent))))
dents))
(maybe-reindex (acons 'index ref '())))))))
(define (maybe-reindex old-index)
(let ((master (git-rev-parse "refs/heads/master")))

View file

@ -257,7 +257,7 @@
" " (label (@ (for "url")) (small "Website")))
(p (input (@ (type "text") (name "x") (value "")
(size "22") (tabindex "3")))
" " (label (@ (for "x")) (small "What's your favorite number?")))
" " (label (@ (for "x")) (small "What's a number between 34 and 42?")))
;(p (small "allowed tags: "))
(p (textarea (@ (name "comment") (id "comment") (cols "65")
(rows "10") (tabindex "4"))