GNU bug report logs -
#70626
30.0.50; shr-correct-dom-case fails for certain svg tags
Previous Next
Reported by: Visuwesh <visuweshm <at> gmail.com>
Date: Sun, 28 Apr 2024 11:17:01 UTC
Severity: normal
Found in version 30.0.50
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
Message #10 received at 70626-done <at> debbugs.gnu.org (full text, mbox):
> From: Visuwesh <visuweshm <at> gmail.com>
> Date: Sun, 28 Apr 2024 16:45:40 +0530
>
> To reproduce:
>
> 1. emacs -Q
> 2. M-s M-w https://l.opnxng.com/r/emacs RET
> 3. Witness the error message in the echo area
>
> The function shr-correct-dom-case eventually passes the children of the
> title tag which is just a string so dom-attributes signals an error
> producing the following backtrace:
>
> Debugger entered--Lisp error: (wrong-type-argument listp "settings")
> car("settings")
> shr-correct-dom-case("settings")
> shr-correct-dom-case((title nil "settings"))
> shr-correct-dom-case((svg ((xmlns . "http://www.w3.org/2000/svg") (width . "24") (height . "24") (viewBox . "0 0 24 24") (fill . "none") (stroke . "currentColor") (stroke-width . "2") (stroke-linecap . "round") (stroke-linejoin . "round")) (title nil "settings") (circle ((cx . "12") (cy . "12") (r . "3"))) (path ((d . "M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z")))))
> shr-tag-svg((svg ((xmlns . "http://www.w3.org/2000/svg") (width . "24") (height . "24") (viewBox . "0 0 24 24") (fill . "none") (stroke . "currentColor") (stroke-width . "2") (stroke-linecap . "round") (stroke-linejoin . "round")) (title nil "settings") (circle ((cx . "12") (cy . "12") (r . "3"))) (path ((d . "M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z")))))
> ...
>
> A minimal self-contained reproducer is the following:
>
> (let ((svg "<svg xmlns=http://www.w3.org/2000/svg width=24 height=24 viewBox=\"0 0 24 24\" fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>
> <title>settings</title>
> <circle cx=12 cy=12 r=3></circle><path d=\"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z\"></path>
> </svg>"))
> (with-temp-buffer
> (insert svg)
> (let ((dom (libxml-parse-html-region)))
> (shr-correct-dom-case (dom-by-tag dom 'svg)))))
>
> The following patch fixes the issue on my end
>
> diff --git a/lisp/net/shr.el b/lisp/net/shr.el
> index 09df5f5a9bb..14b3f7aa163 100644
> --- a/lisp/net/shr.el
> +++ b/lisp/net/shr.el
> @@ -1510,7 +1510,8 @@ shr-correct-dom-case
> (when-let ((rep (assoc-default (car attr) shr-correct-attribute-case)))
> (setcar attr rep)))
> (dolist (child (dom-children dom))
> - (shr-correct-dom-case child))
> + (when (consp child)
> + (shr-correct-dom-case child)))
> dom)
>
> (defun shr-tag-svg (dom)
Thanks, installed on master, and closing the bug.
This bug report was last modified 1 year and 115 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.