Avoid infinite loop when replacing escapes
commit0448121f000bd0a5b046a9900717d7e98e14cbb1
authorCarsten Dominik <carsten.dominik@gmail.com>
Sat, 8 May 2010 05:20:54 +0000 (8 07:20 +0200)
committerCarsten Dominik <carsten.dominik@gmail.com>
Sat, 8 May 2010 05:20:54 +0000 (8 07:20 +0200)
tree82acc2c2cee1850ded29d48818f0cdaf64d05934
parent11327224188ad3e25afa6683cc1d170d0f17646c
Avoid infinite loop when replacing escapes

Patch by David Maus, who writes:

> Org enters an infinite loop when `org-replace-escapes' is called with
> a table containing a replace string that contains the escape sequence
> it should be replaced with.
>
> Example:
> ,----
> | (org-replace-escapes "%m" '(("%m" . "87zl0qq1f3.wl%maus.david@gmail.com")))
> `----
>
> I stumpled upon when I tried to store a link to a internet message
> whose message id contained the sequence "%m" (perfectly valid for a
> message id) while using "%m" as message description.
>
> Attached patch fixes this by
>
>  1. detecting such 'self reference' and replacing the offending
>     sequence in the replace string by a string with a text property
>     that contains the original sequence
>
>  2. replacing occurences of substrings with this text property by the
>     original sequence.
lisp/ChangeLog
lisp/org.el