emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-29 0eddfa28ebd: Avoid slowdowns in xmltok-scan-attributes


From: Gregory Heytings
Subject: emacs-29 0eddfa28ebd: Avoid slowdowns in xmltok-scan-attributes
Date: Sat, 18 Mar 2023 06:51:43 -0400 (EDT)

branch: emacs-29
commit 0eddfa28ebdba3b1e5b3249416f14ea67bd41e3c
Author: Gregory Heytings <gregory@heytings.org>
Commit: Gregory Heytings <gregory@heytings.org>

    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.
---
 lisp/nxml/xmltok.el | 9 +++++++--
 1 file 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."
        (atts-needing-normalization nil))
     (while (cond ((or (looking-at (xmltok-attribute regexp))
                      ;; use non-greedy group
-                     (when (looking-at (concat "[^<>\n]+?"
-                                               (xmltok-attribute regexp)))
+                     ;; Limit the search to 10000 characters, to
+                     ;; avoid slowdowns due to the quadratic
+                     ;; complexity of the regexp.  See bug#61514.
+                     (when (with-restriction
+                             (point) (+ (point) 10000)
+                             (looking-at (concat "[^<>\n]+?"
+                                                 (xmltok-attribute regexp))))
                        (unless recovering
                          (xmltok-add-error "Malformed attribute"
                                            (point)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]