diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 88d477e..8d0dadb 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2010-05-07  David Maus  <dmaus@ictsoc.de>
+
+	* org.el (org-replace-escapes): Avoid infinite loop when
+	replace string contains escape sequence it replaces.
+
 2010-05-07  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org-table.el (org-table-recalculate-buffer-tables)
diff --git a/lisp/org.el b/lisp/org.el
index 463a0eb..b6a0854 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -17644,17 +17644,27 @@ TABLE is an association list with keys like \"%a\" and string values.
 The sequences in STRING may contain normal field width and padding information,
 for example \"%-5s\".  Replacements happen in the sequence given by TABLE,
 so values can contain further %-escapes if they are define later in TABLE."
-  (let ((case-fold-search nil)
-	e re rpl)
-    (while (setq e (pop table))
+  (let ((tbl (copy-alist table))
+	(case-fold-search nil)
+        (pchg 0)
+        e re rpl)
+    (while (setq e (pop tbl))
       (setq re (concat "%-?[0-9.]*" (substring (car e) 1)))
+      (when (string-match re (cdr e))
+        (let ((sref (substring (cdr e) (match-beginning 0) (match-end 0)))
+              (safe "SREF"))
+          (add-text-properties 0 3 (list 'sref sref) safe)
+          (setcdr e (replace-match safe t t (cdr e)))))
       (while (string-match re string)
-	(setq rpl (format (concat (substring (match-string 0 string) 0 -1) "s")
-			  (cdr e)))
-	(setq string (replace-match rpl t t string))))
+        (setq rpl (format (concat (substring (match-string 0 string) 0 -1) "s")
+                          (cdr e)))
+        (setq string (replace-match rpl t t string))))
+    (while (setq pchg (next-property-change pchg string))
+      (let ((sref (get-text-property pchg 'sref string)))
+	(when (and sref (string-match "SREF" string pchg))
+	  (setq string (replace-match sref t t string)))))
     string))
 
-
 (defun org-sublist (list start end)
   "Return a section of LIST, from START to END.
 Counting starts at 1."
