emacs-pretest-bug
[Top][All Lists]
Advanced

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

Re: Stack overflow in regexp matcher when opening file


From: Richard M. Stallman
Subject: Re: Stack overflow in regexp matcher when opening file
Date: Sat, 04 Feb 2006 13:27:02 -0500

This change gets rid of the regexp overflow in that case.
(I think it is simply wrong to use `\s ' here.)

Your change also seems like a good idea.

*** files.el    23 Jan 2006 12:44:39 -0500      1.802
--- files.el    04 Feb 2006 00:55:47 -0500      
***************
*** 2023,2040 ****
  (defvar magic-mode-alist
    `(;; The < comes before the groups (but the first) to reduce backtracking.
      ;; TODO: UTF-16 <?xml may be preceded by a BOM 0xff 0xfe or 0xfe 0xff.
      (,(let* ((incomment-re "\\(?:[^-]\\|-[^-]\\)")
!            (comment-re (concat "\\(?:!--" incomment-re "*-->\\s *<\\)")))
!       (concat "\\(?:<\\?xml\\s +[^>]*>\\)?\\s *<"
                comment-re "*"
!               "\\(?:!DOCTYPE\\s +[^>]*>\\s *<\\s *" comment-re "*\\)?"
                "[Hh][Tt][Mm][Ll]"))
       . html-mode)
      ;; These two must come after html, because they are more general:
      ("<\\?xml " . xml-mode)
      (,(let* ((incomment-re "\\(?:[^-]\\|-[^-]\\)")
!            (comment-re (concat "\\(?:!--" incomment-re "*-->\\s *<\\)")))
!       (concat "\\s *<" comment-re "*!DOCTYPE "))
       . sgml-mode)
      ("%![^V]" . ps-mode)
      ("# xmcd " . conf-unix-mode))
--- 2023,2041 ----
  (defvar magic-mode-alist
    `(;; The < comes before the groups (but the first) to reduce backtracking.
      ;; TODO: UTF-16 <?xml may be preceded by a BOM 0xff 0xfe or 0xfe 0xff.
+     ;; We use [ \t\n] instead of `\\s ' to make regex overflow less likely.
      (,(let* ((incomment-re "\\(?:[^-]\\|-[^-]\\)")
!            (comment-re (concat "\\(?:!--" incomment-re "*-->[ \t\n]*<\\)")))
!       (concat "\\(?:<\\?xml[ \t\n]+[^>]*>\\)?[ \t\n]*<"
                comment-re "*"
!               "\\(?:!DOCTYPE[ \t\n]+[^>]*>[ \t\n]*<[ \t\n]*" comment-re 
"*\\)?"
                "[Hh][Tt][Mm][Ll]"))
       . html-mode)
      ;; These two must come after html, because they are more general:
      ("<\\?xml " . xml-mode)
      (,(let* ((incomment-re "\\(?:[^-]\\|-[^-]\\)")
!            (comment-re (concat "\\(?:!--" incomment-re "*-->[ \t\n]*<\\)")))
!       (concat "[ \t\n]*<" comment-re "*!DOCTYPE "))
       . sgml-mode)
      ("%![^V]" . ps-mode)
      ("# xmcd " . conf-unix-mode))




reply via email to

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