From 8209cb831d0d387d03b10416235d2910a74f80f7 Mon Sep 17 00:00:00 2001 From: David Maus Date: Thu, 23 Sep 2010 20:30:13 +0200 Subject: [PATCH] New algorithm for percent escaping * org.el (org-link-escape): New algorithm for percent escaping. Interate over TEXT and replace chars that are in TABLE or are non-ASCII single byte characters. Multibyte characters are left untouched. --- lisp/org.el | 16 +++++----------- 1 files changed, 5 insertions(+), 11 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index d7aa3d2..2c3f1b7 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -8491,17 +8491,11 @@ This is the list that is used before handing over to the browser.") (if (and org-url-encoding-use-url-hexify (not table)) (url-hexify-string text) (setq table (or table org-link-escape-chars)) - (when text - (let ((re (mapconcat (lambda (x) (regexp-quote - (char-to-string (car x)))) - table "\\|"))) - (while (string-match re text) - (setq text - (replace-match - (cdr (assoc (string-to-char (match-string 0 text)) - table)) - t t text))) - text)))) + (mapconcat (lambda (c) + (if (or (assoc c table) + (and (> c 126) (< c 255))) + (format "%%%X" c) + (char-to-string c))) text ""))) (defun org-link-unescape (text &optional table) "Reverse the action of `org-link-escape'." -- 1.7.1