From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: pok@netfonds.no (Peder O. Klingenberg) Newsgroups: gmane.emacs.bugs Subject: bug#24315: 25.1.50; re-search-forward errors with "Variable binding depth exceeds max-specpdl-size" Date: Tue, 30 Aug 2016 15:09:34 +0200 Message-ID: References: <87twe6sx2g.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1472562636 29181 195.159.176.226 (30 Aug 2016 13:10:36 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 30 Aug 2016 13:10:36 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) Cc: 24315@debbugs.gnu.org To: npostavs@users.sourceforge.net Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Aug 30 15:10:26 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1beio4-0006c3-HN for geb-bug-gnu-emacs@m.gmane.org; Tue, 30 Aug 2016 15:10:24 +0200 Original-Received: from localhost ([::1]:49105 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1beio1-0004qY-7S for geb-bug-gnu-emacs@m.gmane.org; Tue, 30 Aug 2016 09:10:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57048) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1beinn-0004j8-I2 for bug-gnu-emacs@gnu.org; Tue, 30 Aug 2016 09:10:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1beini-0000yh-FM for bug-gnu-emacs@gnu.org; Tue, 30 Aug 2016 09:10:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:46460) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1beini-0000yd-Bf for bug-gnu-emacs@gnu.org; Tue, 30 Aug 2016 09:10:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1beini-0006LO-7J for bug-gnu-emacs@gnu.org; Tue, 30 Aug 2016 09:10:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: pok@netfonds.no (Peder O. Klingenberg) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 30 Aug 2016 13:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24315 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 24315-submit@debbugs.gnu.org id=B24315.147256259424367 (code B ref 24315); Tue, 30 Aug 2016 13:10:02 +0000 Original-Received: (at 24315) by debbugs.gnu.org; 30 Aug 2016 13:09:54 +0000 Original-Received: from localhost ([127.0.0.1]:44172 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1beinV-0006Kr-L2 for submit@debbugs.gnu.org; Tue, 30 Aug 2016 09:09:53 -0400 Original-Received: from hermes.netfonds.no ([80.91.224.195]:34492) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1beinP-0006Kc-Fa for 24315@debbugs.gnu.org; Tue, 30 Aug 2016 09:09:47 -0400 Original-Received: from luna.netfonds.no ([80.91.225.79] helo=luna) by hermes.netfonds.no with esmtp (Exim 4.84_2) (envelope-from ) id 1beinG-00022v-NX; Tue, 30 Aug 2016 15:09:40 +0200 Original-Received: by luna (Postfix, from userid 547) id AD5404E00E3; Tue, 30 Aug 2016 15:09:34 +0200 (CEST) In-Reply-To: <87twe6sx2g.fsf@users.sourceforge.net> (npostavs's message of "Fri, 26 Aug 2016 23:35:51 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:122771 Archived-At: --=-=-= Content-Type: text/plain On Fri, Aug 26 2016 at 23:35, npostavs@users.sourceforge.net wrote: > This looks like it would be an inefficient regexp, since it has nested > stars. I suspect searching for "^[ \t]" multiple times would be more > efficient than trying to match multiple lines in a single regexp. Tried that. It sort of worked, in that it worked when I directly called `icalendar--read-event' in a buffer containing the event as manually extracted from the gnus message. However, parsing the problematic message in gnus still failed. It turns out `gnus-icalendar-event-from-buffer' calls `icalendar--get-unfolded-buffer' before `icalendar--read-event'. `icalendar--get-unfolded-buffer' takes care of all those pesky line continuations, and returns a buffer with each element occupying exactly one line. So essentially `icalendar--read-event' was using a regexp to extract the rest of the line, and that failed with a line nearly 40k characters long. The only other in-tree caller of `icalendar--read-event' (excluding itself) also calls `icalendar--get-unfolded-buffer' first, and indeed, `icalendar-read-event' already relies on this to take care of line continuations in element parameters (as opposed to values). Attached is a patch that uses buffer-substring to accomplish the same thing as the offending regexp, and documents the dependency on `icalendar--get-unfolded-buffer'. This fixes the problem for me. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=bug24315.patch >From c3ae84dc48a993bb1906d5c9b6b663184e2a9d9d Mon Sep 17 00:00:00 2001 From: "Peder O. Klingenberg" Date: Tue, 30 Aug 2016 14:44:16 +0200 Subject: [PATCH] Avoid crash in icalendar--read-element * lisp/calendar/icalendar.el (icalendar--read-element): Stop crashing when parsing overly long event descriptions. (Bug#24315) --- lisp/calendar/icalendar.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el index 386c554..19930d5 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,8 @@ 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))) + (setq value (buffer-substring (point) (line-end-position))) + (end-of-line) (setq line (list name params value)) (cond ((eq name 'BEGIN) (setq children -- 2.9.3 --=-=-=--