From: David Lichteblau Date: Sun, 23 Mar 2008 18:43:52 +0000 (+0100) Subject: don't escape < in attributes X-Git-Url: https://repo.or.cz/w/closure-html.git/commitdiff_plain/f523d3764f5d2f4b863728a6c104ad924bed9ef2 don't escape < in attributes --- diff --git a/doc/index.xml b/doc/index.xml index ca41e1c..1ed6410 100644 --- a/doc/index.xml +++ b/doc/index.xml @@ -59,7 +59,22 @@
  • - Fixed serialization of unknown elements. + Serialization fixes: +
  • New argument documentp to serialize-pt. diff --git a/src/parse/unparse.lisp b/src/parse/unparse.lisp index 73b3b8c..c8bbcc9 100644 --- a/src/parse/unparse.lisp +++ b/src/parse/unparse.lisp @@ -89,7 +89,7 @@ (unless (and att (listp values) (eq (car att) (car values))) (%write-rune #/= sink) (%write-rune #/\" sink) - (unparse-string (hax:attribute-value a) sink) + (unparse-attribute-string (hax:attribute-value a) sink) (%write-rune #/\" sink)))) (%write-rune #/> sink))) @@ -125,6 +125,10 @@ (let ((y (sink-ystream sink))) (loop for rune across str do (unparse-datachar rune y)))) +(defun unparse-attribute-string (str sink) + (let ((y (sink-ystream sink))) + (loop for rune across str do (unparse-attribute-char rune y)))) + (defun unparse-datachar (c ystream) (cond ((rune= c #/&) (write-rod '#.(string-rod "&") ystream)) ((rune= c #/<) (write-rod '#.(string-rod "<") ystream)) @@ -145,6 +149,14 @@ (t (write-rune c ystream)))) +(defun unparse-attribute-char (c ystream) + (cond ((rune= c #/&) (write-rod '#.(string-rod "&") ystream)) + ((rune= c #/\") (write-rod '#.(string-rod """) ystream)) + ((rune= c #/U+000A) (write-rod '#.(string-rod " ") ystream)) + ((rune= c #/U+000D) (write-rod '#.(string-rod " ") ystream)) + (t + (write-rune c ystream)))) + (defun unparse-dtd-string (str sink) (let ((y (sink-ystream sink))) (loop for rune across str do (unparse-dtd-char rune y))))