emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Fix for infinite loop in org-html-protect
@ 2011-03-11 17:30 Kim Rutherford
  2011-03-11 17:38 ` [Accepted] [O] " Bastien Guerry
  2011-03-11 17:39 ` [PATCH] " Bastien
  0 siblings, 2 replies; 6+ messages in thread
From: Kim Rutherford @ 2011-03-11 17:30 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: message body text --]
[-- Type: text/plain, Size: 161 bytes --]

When I export the following as HTML, emacs hangs in org-html-protect:

#+begin_src org
&
#+end_src

The attached patch fixes the problem for me.

Thanks,
Kim.



[-- Attachment #2: Patch for org mode --]
[-- Type: text/plain, Size: 737 bytes --]

From cfb1ccb6f9cfd84530c73b7f72d686a2062b3c3b Mon Sep 17 00:00:00 2001
From: Kim Rutherford <kmr44@cam.ac.uk>
Date: Fri, 11 Mar 2011 16:44:09 +0000
Subject: [PATCH] Fix infinite loop in org-html-protect

---
 lisp/org-html.el |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lisp/org-html.el b/lisp/org-html.el
index c60c90d..2312b21 100644
--- a/lisp/org-html.el
+++ b/lisp/org-html.el
@@ -2186,7 +2186,7 @@ Possible conversions are set in `org-export-html-protect-char-alist'."
       (let ((start 0))
 	(while (string-match (car c) s start)
 	  (setq s (replace-match (cdr c) t t s)
-		start (match-beginning 0)))))
+		start (1+ (match-beginning 0))))))
     s))
 
 (defun org-html-expand (string)
-- 
1.7.1


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

* [Accepted] [O] Fix for infinite loop in org-html-protect
  2011-03-11 17:30 [PATCH] Fix for infinite loop in org-html-protect Kim Rutherford
@ 2011-03-11 17:38 ` Bastien Guerry
  2011-03-11 18:17   ` Scott Frazer
  2011-03-11 17:39 ` [PATCH] " Bastien
  1 sibling, 1 reply; 6+ messages in thread
From: Bastien Guerry @ 2011-03-11 17:38 UTC (permalink / raw)
  To: emacs-orgmode

Patch 674 (http://patchwork.newartisans.com/patch/674/) is now "Accepted".

Maintainer comment: none

This relates to the following submission:

http://mid.gmane.org/%3C19834.23619.813886.886825%40gargle.gargle.HOWL%3E

Here is the original message containing the patch:

> Content-Type: text/plain; charset="utf-8"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Subject: [O] Fix for infinite loop in org-html-protect
> Date: Fri, 11 Mar 2011 22:30:43 -0000
> From: Kim Rutherford <kmr44@cam.ac.uk>
> X-Patchwork-Id: 674
> Message-Id: <19834.23619.813886.886825@gargle.gargle.HOWL>
> To: emacs-orgmode@gnu.org
> 
> When I export the following as HTML, emacs hangs in org-html-protect:
> 
> #+begin_src org
> &
> #+end_src
> 
> The attached patch fixes the problem for me.
> 
> Thanks,
> Kim.
> >From cfb1ccb6f9cfd84530c73b7f72d686a2062b3c3b Mon Sep 17 00:00:00 2001
> From: Kim Rutherford <kmr44@cam.ac.uk>
> Date: Fri, 11 Mar 2011 16:44:09 +0000
> Subject: [PATCH] Fix infinite loop in org-html-protect
> 
> ---
> lisp/org-html.el |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/lisp/org-html.el b/lisp/org-html.el
> index c60c90d..2312b21 100644
> --- a/lisp/org-html.el
> +++ b/lisp/org-html.el
> @@ -2186,7 +2186,7 @@ Possible conversions are set in `org-export-html-protect-char-alist'."
>        (let ((start 0))
>  	(while (string-match (car c) s start)
>  	  (setq s (replace-match (cdr c) t t s)
> -		start (match-beginning 0)))))
> +		start (1+ (match-beginning 0))))))
>      s))
>  
>  (defun org-html-expand (string)
> 

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

* Re: [PATCH] Fix for infinite loop in org-html-protect
  2011-03-11 17:30 [PATCH] Fix for infinite loop in org-html-protect Kim Rutherford
  2011-03-11 17:38 ` [Accepted] [O] " Bastien Guerry
@ 2011-03-11 17:39 ` Bastien
  1 sibling, 0 replies; 6+ messages in thread
From: Bastien @ 2011-03-11 17:39 UTC (permalink / raw)
  To: kmr44; +Cc: emacs-orgmode

Hi Kim,

Kim Rutherford <kmr44@cam.ac.uk> writes:

> When I export the following as HTML, emacs hangs in org-html-protect:
>
> #+begin_src org
> &
> #+end_src
>
> The attached patch fixes the problem for me.

Applied -- your patch is faaaaar better than the one I pushed, thanks.

-- 
 Bastien

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

* Re: [Accepted] [O] Fix for infinite loop in org-html-protect
  2011-03-11 17:38 ` [Accepted] [O] " Bastien Guerry
@ 2011-03-11 18:17   ` Scott Frazer
  2011-03-11 18:55     ` Nick Dokos
  0 siblings, 1 reply; 6+ messages in thread
From: Scott Frazer @ 2011-03-11 18:17 UTC (permalink / raw)
  To: Bastien Guerry; +Cc: emacs-orgmode

On 3/11/11 12:38 PM, Bastien Guerry wrote:

>>
>> ---
>> lisp/org-html.el |    2 +-
>>   1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/lisp/org-html.el b/lisp/org-html.el
>> index c60c90d..2312b21 100644
>> --- a/lisp/org-html.el
>> +++ b/lisp/org-html.el
>> @@ -2186,7 +2186,7 @@ Possible conversions are set in `org-export-html-protect-char-alist'."
>>         (let ((start 0))
>>   	(while (string-match (car c) s start)
>>   	  (setq s (replace-match (cdr c) t t s)
>> -		start (match-beginning 0)))))
>> +		start (1+ (match-beginning 0))))))
>>       s))
>>
>>   (defun org-html-expand (string)
>>

I think there might be a second bug in that function that I had to fix myself.
I don't know the proper way to create/submit a patch, but instead of this:

     (while (setq c (pop cl))
       (while (string-match (car c) s start)

I think you need this:

     (while (setq c (pop cl))
       (setq start 0)
       (while (string-match (car c) s start)

i.e. you need to start over at the beginning of the line each time you go
through the list of protected chars, or else you'll start from the last
replacement location.

Scott

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

* Re: [Accepted] [O] Fix for infinite loop in org-html-protect
  2011-03-11 18:17   ` Scott Frazer
@ 2011-03-11 18:55     ` Nick Dokos
  2011-03-11 19:12       ` Scott Frazer
  0 siblings, 1 reply; 6+ messages in thread
From: Nick Dokos @ 2011-03-11 18:55 UTC (permalink / raw)
  To: Scott Frazer; +Cc: Bastien Guerry, nicholas.dokos, emacs-orgmode

Scott Frazer <frazer.scott@gmail.com> wrote:

> On 3/11/11 12:38 PM, Bastien Guerry wrote:
> 
> >>
> >> ---
> >> lisp/org-html.el |    2 +-
> >>   1 files changed, 1 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/lisp/org-html.el b/lisp/org-html.el
> >> index c60c90d..2312b21 100644
> >> --- a/lisp/org-html.el
> >> +++ b/lisp/org-html.el
> >> @@ -2186,7 +2186,7 @@ Possible conversions are set in `org-export-html-protect-char-alist'."
> >>         (let ((start 0))
> >>   	(while (string-match (car c) s start)
> >>   	  (setq s (replace-match (cdr c) t t s)
> >> -		start (match-beginning 0)))))
> >> +		start (1+ (match-beginning 0))))))
> >>       s))
> >>
> >>   (defun org-html-expand (string)
> >>
> 
> I think there might be a second bug in that function that I had to fix myself.
> I don't know the proper way to create/submit a patch, but instead of this:
> 
>     (while (setq c (pop cl))
>       (while (string-match (car c) s start)
> 
> I think you need this:
> 
>     (while (setq c (pop cl))
>       (setq start 0)
>       (while (string-match (car c) s start)
> 
> i.e. you need to start over at the beginning of the line each time you go
> through the list of protected chars, or else you'll start from the last
> replacement location.
> 

There is a (let ((start 0))... around the (while (string-match...)..)
and inside the outer loop, so every time the inner loop is finished,
start is recreated and initialized to 0 for the next iteration of the
outer loop. At least, that's the case in latest git.

Nick

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

* Re: [Accepted] [O] Fix for infinite loop in org-html-protect
  2011-03-11 18:55     ` Nick Dokos
@ 2011-03-11 19:12       ` Scott Frazer
  0 siblings, 0 replies; 6+ messages in thread
From: Scott Frazer @ 2011-03-11 19:12 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: Bastien Guerry, emacs-orgmode

On Fri, Mar 11, 2011 at 1:55 PM, Nick Dokos <nicholas.dokos@hp.com> wrote:
> Scott Frazer <frazer.scott@gmail.com> wrote:
> There is a (let ((start 0))... around the (while (string-match...)..)
> and inside the outer loop, so every time the inner loop is finished,
> start is recreated and initialized to 0 for the next iteration of the
> outer loop. At least, that's the case in latest git.
>

Okay, it must have already been fixed then.  I am on the 7.5 tag, so I should
probably move to the latest.

Scott

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

end of thread, other threads:[~2011-03-11 19:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-11 17:30 [PATCH] Fix for infinite loop in org-html-protect Kim Rutherford
2011-03-11 17:38 ` [Accepted] [O] " Bastien Guerry
2011-03-11 18:17   ` Scott Frazer
2011-03-11 18:55     ` Nick Dokos
2011-03-11 19:12       ` Scott Frazer
2011-03-11 17:39 ` [PATCH] " Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).