diff options
| author | Gregory Heytings | 2023-03-18 10:49:29 +0000 |
|---|---|---|
| committer | Gregory Heytings | 2023-03-18 11:51:32 +0100 |
| commit | 0eddfa28ebdba3b1e5b3249416f14ea67bd41e3c (patch) | |
| tree | 2fadbac295e64fc962f81e25853ba35cd2dde91b | |
| parent | 647c6bf2a6ce7113de5dae251633eaba27627a62 (diff) | |
| download | emacs-0eddfa28ebdba3b1e5b3249416f14ea67bd41e3c.tar.gz emacs-0eddfa28ebdba3b1e5b3249416f14ea67bd41e3c.zip | |
Avoid slowdowns in xmltok-scan-attributes
* lisp/nxml/xmltok.el (xmltok-scan-attributes): Limit the search
to 10000 characters, to avoid slowdowns due to the quadratic
complexity of the regexp. Suggested by Stefan Monnier.
| -rw-r--r-- | lisp/nxml/xmltok.el | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lisp/nxml/xmltok.el b/lisp/nxml/xmltok.el index c36d225c7c9..fb852e5ea5e 100644 --- a/lisp/nxml/xmltok.el +++ b/lisp/nxml/xmltok.el | |||
| @@ -734,8 +734,13 @@ and VALUE-END, otherwise a STRING giving the value." | |||
| 734 | (atts-needing-normalization nil)) | 734 | (atts-needing-normalization nil)) |
| 735 | (while (cond ((or (looking-at (xmltok-attribute regexp)) | 735 | (while (cond ((or (looking-at (xmltok-attribute regexp)) |
| 736 | ;; use non-greedy group | 736 | ;; use non-greedy group |
| 737 | (when (looking-at (concat "[^<>\n]+?" | 737 | ;; Limit the search to 10000 characters, to |
| 738 | (xmltok-attribute regexp))) | 738 | ;; avoid slowdowns due to the quadratic |
| 739 | ;; complexity of the regexp. See bug#61514. | ||
| 740 | (when (with-restriction | ||
| 741 | (point) (+ (point) 10000) | ||
| 742 | (looking-at (concat "[^<>\n]+?" | ||
| 743 | (xmltok-attribute regexp)))) | ||
| 739 | (unless recovering | 744 | (unless recovering |
| 740 | (xmltok-add-error "Malformed attribute" | 745 | (xmltok-add-error "Malformed attribute" |
| 741 | (point) | 746 | (point) |