Subject: Re: bug#24315: 25.1.50; re-search-forward errors with "Variable binding depth exceeds max-specpdl-size"

From: [email-masked] (Peder O. Klingenberg)
Date: Tue, 06 Sep 2016 10:18:13 +0200

On Sat, Sep 03 2016 at 10:21, [email-masked] wrote:

> Patch looks good, though I think the description shouldn't say "crash",
> since the problem is a regex stack overflow, which is just a normal
> Emacs error

I agree, that was a poor choice of words.  How about this?

>From bd28797ce52c070e59d26483bdf842fd31651de6 Mon Sep 17 00:00:00 2001
From: "Peder O. Klingenberg" <[email-masked]>
Date: Tue, 30 Aug 2016 14:44:16 +0200
Subject: [PATCH] Avoid error in icalendar--read-element

* lisp/calendar/icalendar.el (icalendar--read-element): Avoid a regex
stack overflow by not using regex to extract values from calendar
events. (Bug#24315)
---
 lisp/calendar/icalendar.el | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el
index 386c554..c88f4ab 100644
--- a/lisp/calendar/icalendar.el
+++ b/lisp/calendar/icalendar.el
@@ -361,7 +361,8 @@ icalendar--read-element
 INVALUE gives the current iCalendar element we are reading.
 INPARAMS gives the current parameters.....
 This function calls itself recursively for each nested calendar element
-it finds."
+it finds.  The current buffer should be an unfolded buffer as returned
+from `icalendar--get-unfolded-buffer'."
   (let (element children line name params param param-name param-value
                 value
                 (continue t))
@@ -391,8 +392,9 @@ icalendar--read-element
       (unless (looking-at ":")
         (error "Oops"))
       (forward-char 1)
-      (re-search-forward  "\\(.*\\)\\(\r?\n[ \t].*\\)*" nil t)
-      (setq value (icalendar--rris "\r?\n[ \t]" "" (match-string 0)))
+      (let ((start (point)))
+        (end-of-line)
+        (setq value (buffer-substring start (point))))
       (setq line (list name params value))
       (cond ((eq name 'BEGIN)
              (setq children
-- 
2.9.3