diff --git a/tekuti/comment.scm b/tekuti/comment.scm index f177082..fbcff6b 100644 --- a/tekuti/comment.scm +++ b/tekuti/comment.scm @@ -92,11 +92,18 @@ #f `(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."))) + (define *new-comment-spec* `(("author" ,(lambda (x) #f)) ("email" ,bad-email?) ("url" ,bad-url?) ("comment" ,bad-user-submitted-xhtml?) + ("x" ,bad-number?) ("submit" ,(lambda (x) #f)))) (define (bad-new-comment-post? post-data) diff --git a/tekuti/page-helpers.scm b/tekuti/page-helpers.scm index bb998d0..b82f0ad 100644 --- a/tekuti/page-helpers.scm +++ b/tekuti/page-helpers.scm @@ -120,6 +120,9 @@ (p (input (@ (type "text") (name "url") (value ,url) (size "22") (tabindex "3"))) " " (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?"))) ;(p (small "allowed tags: ")) (p (textarea (@ (name "comment") (id "comment") (cols "65") (rows "10") (tabindex "4")) diff --git a/tekuti/util.scm b/tekuti/util.scm index 81a4d0b..dcef7a2 100644 --- a/tekuti/util.scm +++ b/tekuti/util.scm @@ -39,13 +39,13 @@ list-intersperse with-backtrace with-time-debugging define-memoized)) (define (emailish? x) - (match-bind "^([a-zA-Z0-9.+-]+)@([a-zA-Z0-9-]+\\.)+[a-zA-Z]+$" + (match-bind "^([a-zA-Z0-9._+-]+)@([a-zA-Z0-9-]+\\.)+[a-zA-Z]+$" x (_ . args) x #f)) (define (urlish? x) - (match-bind "^https?://([a-zA-Z0-9-]+\\.)+[a-zA-Z]+/[a-zA-Z0-9$_.+!*'(),;/?:@&=-]*$" + (match-bind "^https?://([a-zA-Z0-9-]+\\.)+[a-zA-Z]+(/[a-zA-Z0-9$_.+!*'(),;/?:@&=-]*)?$" x (_ . args) x #f))