1
0
Fork 0

Make raw text closing tag check reflect the spec

* tekuti/page-helpers.scm (shtml->html): The previous code was too
  strict.
This commit is contained in:
Andy Wingo 2019-05-31 16:11:32 +02:00
parent 5cdda50445
commit 83c47a9185

View file

@ -187,8 +187,17 @@ present."
(cond
((raw-text-element? tag)
(let ((body (string-concatenate body)))
(when (string-contains body "</")
(error "raw text element body contains </" tag attrs body))
(let ((needle (string-append "</" (symbol->string tag))))
(let lp ((idx 0))
(let ((idx (string-contains-ci body needle idx)))
(when idx
(let ((idx (+ idx (string-length needle))))
(let ((ch (and (< idx (string-length body))
(string-ref body idx))))
(when (and ch (string-index "\t\n\f\r >/" ch))
(error "raw text element body contains end tag"
needle body)))
(lp idx))))))
(display body port)))
((escapable-raw-text-element? tag)
(for-each