; Use HTML entities for reserved characters in 'dom-print'
* lisp/dom.el (dom-print): Encode HTML reserved characters in strings. * test/lisp/dom-tests.el (dom-tests-print): New test. (Bug#68508)
This commit is contained in:
parent
b3e4fbe867
commit
3a5ee06057
2 changed files with 11 additions and 1 deletions
|
@ -288,7 +288,7 @@ If XML, generate XML instead of HTML."
|
|||
(insert ">")
|
||||
(dolist (child children)
|
||||
(if (stringp child)
|
||||
(insert child)
|
||||
(insert (url-insert-entities-in-string child))
|
||||
(setq non-text t)
|
||||
(when pretty
|
||||
(insert "\n" (make-string (+ column 2) ?\s)))
|
||||
|
|
|
@ -209,6 +209,16 @@ child results in an error."
|
|||
(dom-pp node t)
|
||||
(should (equal (buffer-string) "(\"foo\" nil)")))))
|
||||
|
||||
(ert-deftest dom-tests-print ()
|
||||
"Test that `dom-print' correctly encodes HTML reserved characters."
|
||||
(with-temp-buffer
|
||||
(dom-print '(samp ((class . "samp")) "<div class=\"default\"> </div>"))
|
||||
(should (equal
|
||||
(buffer-string)
|
||||
(concat "<samp class=\"samp\">"
|
||||
"<div class="default"> </div>"
|
||||
"</samp>")))))
|
||||
|
||||
(ert-deftest dom-test-search ()
|
||||
(let ((dom '(a nil (b nil (c nil)))))
|
||||
(should (equal (dom-search dom (lambda (d) (eq (dom-tag d) 'a)))
|
||||
|
|
Loading…
Add table
Reference in a new issue