Gnus development mailing list
 help / color / mirror / Atom feed
* [PATCH] Match lone lines in imap efficiently
@ 2011-05-19  1:19 Roger
  2011-05-19  8:55 ` Matthias Andree
  2011-05-30 18:26 ` Lars Magne Ingebrigtsen
  0 siblings, 2 replies; 3+ messages in thread
From: Roger @ 2011-05-19  1:19 UTC (permalink / raw)
  To: ding; +Cc: Roger

When some email with large number of recipients is hit, Gnus
will hit error "Stack overflow in regexp matcher"
---
 lisp/nnimap.el |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/nnimap.el b/lisp/nnimap.el
index 6882ed6..967cb36 100644
--- a/lisp/nnimap.el
+++ b/lisp/nnimap.el
@@ -190,7 +190,7 @@ textual parts.")
   (let (article bytes lines size string)
     (block nil
       (while (not (eobp))
-	(while (not (looking-at "^\\* [0-9]+ FETCH.*UID \\([0-9]+\\)"))
+	(while (not (looking-at "^\\* [0-9]+ FETCH[[:space:](]*UID \\([0-9]+\\)"))
 	  (delete-region (point) (progn (forward-line 1) (point)))
 	  (when (eobp)
 	    (return)))
@@ -1904,7 +1904,7 @@ textual parts.")
   (let (article bytes)
     (block nil
       (while (not (eobp))
-	(while (not (looking-at "^\\* [0-9]+ FETCH.*UID \\([0-9]+\\)"))
+	(while (not (looking-at "^\\* [0-9]+ FETCH[[:space:](]*UID \\([0-9]+\\)"))
 	  (delete-region (point) (progn (forward-line 1) (point)))
 	  (when (eobp)
 	    (return)))
-- 
1.7.5.1




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Match lone lines in imap efficiently
  2011-05-19  1:19 [PATCH] Match lone lines in imap efficiently Roger
@ 2011-05-19  8:55 ` Matthias Andree
  2011-05-30 18:26 ` Lars Magne Ingebrigtsen
  1 sibling, 0 replies; 3+ messages in thread
From: Matthias Andree @ 2011-05-19  8:55 UTC (permalink / raw)
  To: Roger; +Cc: ding

Am 19.05.2011 03:19, schrieb Roger:
> When some email with large number of recipients is hit, Gnus
> will hit error "Stack overflow in regexp matcher"
> ---
>  lisp/nnimap.el |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lisp/nnimap.el b/lisp/nnimap.el
> index 6882ed6..967cb36 100644
> --- a/lisp/nnimap.el
> +++ b/lisp/nnimap.el
> @@ -190,7 +190,7 @@ textual parts.")
>    (let (article bytes lines size string)
>      (block nil
>        (while (not (eobp))
> -	(while (not (looking-at "^\\* [0-9]+ FETCH.*UID \\([0-9]+\\)"))
> +	(while (not (looking-at "^\\* [0-9]+ FETCH[[:space:](]*UID \\([0-9]+\\)"))
>  	  (delete-region (point) (progn (forward-line 1) (point)))
>  	  (when (eobp)
>  	    (return)))
> @@ -1904,7 +1904,7 @@ textual parts.")
>    (let (article bytes)
>      (block nil
>        (while (not (eobp))
> -	(while (not (looking-at "^\\* [0-9]+ FETCH.*UID \\([0-9]+\\)"))
> +	(while (not (looking-at "^\\* [0-9]+ FETCH[[:space:](]*UID \\([0-9]+\\)"))
>  	  (delete-region (point) (progn (forward-line 1) (point)))
>  	  (when (eobp)
>  	    (return)))

While it may fix the immediate problem, it looks pretty bogus to me and
will break IMAP functionality with some servers, depending on response
format.

I think dumb regexps aren't the right approach for IMAP parsing,
instead, the reply should be properly parsed into keywords.

1. RFC3501 demands that there is exactly one SP between the FETCH
keyword and the sequence set.

2. The open parenthesis isn't optional before UID - it must be somewhere
between FETCH and UID.

3. Other keywords can come before the UID, see p. 61 in RFC3501. Your
patch breaks that.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Match lone lines in imap efficiently
  2011-05-19  1:19 [PATCH] Match lone lines in imap efficiently Roger
  2011-05-19  8:55 ` Matthias Andree
@ 2011-05-30 18:26 ` Lars Magne Ingebrigtsen
  1 sibling, 0 replies; 3+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-05-30 18:26 UTC (permalink / raw)
  To: ding

Roger <wenrui@gmail.com> writes:

> When some email with large number of recipients is hit, Gnus
> will hit error "Stack overflow in regexp matcher"

[...]

> -	(while (not (looking-at "^\\* [0-9]+ FETCH.*UID \\([0-9]+\\)"))
> +	(while (not (looking-at "^\\* [0-9]+ FETCH[[:space:](]*UID
> \\([0-9]+\\)"

This isn't quite correct (in particular, there may be other things
between FETCH and UID), but I've simplified the regexp in other ways
which may help.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-05-30 18:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-19  1:19 [PATCH] Match lone lines in imap efficiently Roger
2011-05-19  8:55 ` Matthias Andree
2011-05-30 18:26 ` Lars Magne Ingebrigtsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).