浏览代码

Avoid HTML processing of image specifiers in link descriptions.

A link to an image can function as the description part of a link, to
create a clickable image.  The corresponding image tag was
erroneously processed like normal text.  This patch protects such
descriptions from processing.

Reported by Richard Riley.
Carsten Dominik 16 年之前
父节点
当前提交
0d36db1d39
共有 2 个文件被更改,包括 9 次插入2 次删除
  1. 5 0
      lisp/ChangeLog
  2. 4 2
      lisp/org-exp.el

+ 5 - 0
lisp/ChangeLog

@@ -1,5 +1,10 @@
 2008-11-17  Carsten Dominik  <carsten.dominik@gmail.com>
 2008-11-17  Carsten Dominik  <carsten.dominik@gmail.com>
 
 
+	* org-exp.el (org-export-html-format-desc): Respect the
+	org-protect property.
+	(org-export-as-html): Protect image specifiers that are in the
+	description part of a link.
+
 	* org.el (org-sort-entries-or-items, org-completing-read)
 	* org.el (org-sort-entries-or-items, org-completing-read)
 	(org-refile-get-location, org-olpath-completing-read, org-todo)
 	(org-refile-get-location, org-olpath-completing-read, org-todo)
 	(org-show-todo-tree, org-sparse-tree, org-make-tags-matcher)
 	(org-show-todo-tree, org-sparse-tree, org-make-tags-matcher)

+ 4 - 2
lisp/org-exp.el

@@ -3245,7 +3245,9 @@ lang=\"%s\" xml:lang=\"%s\">
 	      (save-match-data
 	      (save-match-data
 		(if (string-match "^file:" desc)
 		(if (string-match "^file:" desc)
 		    (setq desc (substring desc (match-end 0)))))
 		    (setq desc (substring desc (match-end 0)))))
-	      (setq desc (concat "<img src=\"" desc "\"/>")))
+	      (setq desc (org-add-props
+			     (concat "<img src=\"" desc "\"/>")
+			     '(org-protected t))))
 	    ;; FIXME: do we need to unescape here somewhere?
 	    ;; FIXME: do we need to unescape here somewhere?
 	    (cond
 	    (cond
 	     ((equal type "internal")
 	     ((equal type "internal")
@@ -3623,7 +3625,7 @@ lang=\"%s\" xml:lang=\"%s\">
 
 
 (defun org-export-html-format-desc (s)
 (defun org-export-html-format-desc (s)
   "Make sure the S is valid as a description in a link."
   "Make sure the S is valid as a description in a link."
-  (if s
+  (if (and s (not (get-text-property 1 'org-protected s)))
       (save-match-data
       (save-match-data
 	(org-html-do-expand s))
 	(org-html-do-expand s))
     s))
     s))