[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#13802: stack overflow in mm-add-meta-html-tag
From: |
Lars Ingebrigtsen |
Subject: |
bug#13802: stack overflow in mm-add-meta-html-tag |
Date: |
Thu, 30 Jan 2014 16:38:49 -0800 |
User-agent: |
Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50 (gnu/linux) |
Juri Linkov <juri@jurta.org> writes:
>> I see a "Stack overflow in regexp matcher" error traceable back to
>> lisp/gnus/mm-decode.el func ‘mm-add-meta-html-tag’ fragment:
>>
>> (re-search-forward "\
>> <meta\\s-+http-equiv=[\"']?content-type[\"']?\\s-+content=[\"']\
>> text/\\(\\sw+\\)\\(?:\;\\s-*charset=\\(.+\\)\\)?[\"'][^>]*>" nil t)
>>
>> To allow the user (not me) to continue, i kludged the form to be:
>>
>> (ignore-errors
>> (re-search-forward "..." nil t))
>>
>> that is, wrapping w/ ‘ignore-errors’. Is there a better solution?
>
> `sgml-html-meta-auto-coding-function' uses a similar regexp
> that doesn't fail with stack overflow. You could get some ideas
> from this regexp and sync the regexp in `mm-add-meta-html-tag' with it.
I've adapted the regexp from that function in the patch below, but since
I don't have a test case, I'm not really sure about committing it.
Thien-Thi, could you post the message that triggers this error, or the
relevant bits of it?
diff --git a/lisp/mm-decode.el b/lisp/mm-decode.el
index 17c8fb1..eaf9de4 100644
--- a/lisp/mm-decode.el
+++ b/lisp/mm-decode.el
@@ -1405,9 +1405,7 @@ Return t if meta tag is added or replaced."
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\">" charset))
(let ((case-fold-search t))
(goto-char (point-min))
- (if (re-search-forward "\
-<meta\\s-+http-equiv=[\"']?content-type[\"']?\\s-+content=[\"']\
-text/\\(\\sw+\\)\\(?:\;\\s-*charset=\\([^\"'>]+\\)\\)?[^>]*>" nil t)
+ (if (re-search-forward
"<meta\\s-+\\http-equiv=[\"']?content-type[\"']?\\s-+content=[\"']text/\\(\\sw+\\)\\(?:;\\s-*?charset=[\"']?\\(.+?\\)\\)[\"'\\s-/>]"
nil t)
(if (and (not force-charset)
(match-beginning 2)
(string-match "\\`html\\'" (match-string 1)))
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog http://lars.ingebrigtsen.no/
- bug#13802: stack overflow in mm-add-meta-html-tag,
Lars Ingebrigtsen <=