summaryrefslogtreecommitdiff
path: root/haunt
diff options
context:
space:
mode:
authorJakob L. Kreuze <zerodaysfordays@sdf.org>2022-11-08 20:49:48 -0500
committerJakob L. Kreuze <zerodaysfordays@sdf.org>2022-11-15 18:58:09 -0500
commit5074f14e00f00fb0343fadcf7b2ec1c33c8efaaf (patch)
treedc1f34ef94b8cfba539344a8df80251f949971c1 /haunt
parentecfc5b6d209e305a76c5540e8d7f786571a1d8e8 (diff)
[dynamic] Drop (hashing) for (gcrypt hash)
Since it's a more standard Guile dependency, meaning I don't need to bing out Akku for something as simple as calling a hash function.
Diffstat (limited to 'haunt')
-rw-r--r--haunt/jakob/utils/comments.scm29
1 files changed, 22 insertions, 7 deletions
diff --git a/haunt/jakob/utils/comments.scm b/haunt/jakob/utils/comments.scm
index a1deea7..65befca 100644
--- a/haunt/jakob/utils/comments.scm
+++ b/haunt/jakob/utils/comments.scm
@@ -17,24 +17,39 @@
(define-module (jakob utils comments)
;; #:use-module (dynamic capabilities comments)
#:use-module (dynamic util)
- #:use-module (hashing md5)
+ #:use-module (gcrypt base16)
+ #:use-module (gcrypt hash)
#:use-module (ice-9 receive)
#:use-module (ice-9 iconv)
#:use-module (ice-9 match)
#:use-module (srfi srfi-19)
#:use-module (srfi srfi-43)
+ #:use-module (srfi-197)
#:use-module (json)
#:use-module (web client)
#:use-module (web response)
#:export (render-comment-view fetch-comments))
(define (gravatar-url email)
- (format #f "https://www.gravatar.com/avatar/~a" (md5->string (md5 (string->bytevector (string-trim-both (string-downcase email)) "utf8")))))
-;; (chain email
-;; (string-downcase _)
-;; (string-trim-both _)
-;; (string->bytevector _ "utf8")
-;; (md5 _))
+ (chain email
+ (string-downcase _)
+ (string-trim-both _)
+ (string->bytevector _ "utf8")
+ (bytevector-hash _ (lookup-hash-algorithm 'md5))
+ (bytevector->base16-string _)
+ (format #f "https://www.gravatar.com/avatar/~a" _)))
+
+(define (safe-markdown->sxml text)
+ "Convert TEXT to an sxml form filtering out any unsafe entities"
+ (define (sanitize sexp)
+ (cond ((and (list? sexp)
+ (positive? (length sexp))
+ (eqv? 'img (car sexp)))
+ #f)
+ ((list? sexp)
+ (filter identity (map sanitize sexp)))
+ (else sexp)))
+ (sanitize (commonmark->sxml text)))
(define (format-comment comment)
"Format `comment', an alist, as SXML for a comment-type interaction"