yatex
changeset 153:207f0b4af9df dev
Unescape URL strings from buffer(yahtml-unescape-string).
author | yuuji@gentei.org |
---|---|
date | Sat, 06 Nov 2010 19:24:34 +0900 |
parents | 095a5c97ecac |
children | d3bcc4e2166a |
files | yahtml.el |
diffstat | 1 files changed, 20 insertions(+), 4 deletions(-) [+] |
line diff
1.1 --- a/yahtml.el Wed Oct 20 12:36:36 2010 +0900 1.2 +++ b/yahtml.el Sat Nov 06 19:24:34 2010 +0900 1.3 @@ -1,6 +1,6 @@ 1.4 ;;; -*- Emacs-Lisp -*- 1.5 ;;; (c) 1994-2010 by HIROSE Yuuji [yuuji(@)yatex.org] 1.6 -;;; Last modified Mon Sep 13 08:09:46 2010 on firestorm 1.7 +;;; Last modified Sat Nov 6 19:22:54 2010 on firestorm 1.8 ;;; $Id$ 1.9 1.10 (defconst yahtml-revision-number "1.74.2" 1.11 @@ -1051,6 +1051,21 @@ 1.12 (setq str (substring str (1+ p)))) 1.13 (concat target str))))) 1.14 1.15 +(defun yahtml-unescape-string (str) 1.16 + "Untranslate reserved URL-encoded string." 1.17 + (let ((p 0) c (target "") (md (match-data)) (case-fold-search nil)) 1.18 + (unwind-protect 1.19 + (progn 1.20 + (while (string-match "%\\([0-9a-f][0-9a-f]\\)" str p) 1.21 + (setq target (concat target 1.22 + (substring str p (1- (match-beginning 1)))) 1.23 + p (match-end 0) 1.24 + c (YaTeX-hex (substring 1.25 + str (match-beginning 1) (match-end 1))) 1.26 + target (concat target (format "%c" c)))) 1.27 + (concat target (substring str p))) 1.28 + (store-match-data md)))) 1.29 + 1.30 (defun yahtml-escape-chars-region (beg end) 1.31 "Translate reserved chars to encoded string in the region." 1.32 (interactive "r") 1.33 @@ -1711,7 +1726,7 @@ 1.34 (skip-chars-forward " \t\n") 1.35 (looking-at "\"?\\([^\"> \t\n]+\\)\"?")) 1.36 (< p (match-end 0)) 1.37 - (YaTeX-match-string 1))))) 1.38 + (yahtml-unescape-string (YaTeX-match-string 1)))))) 1.39 1.40 (defun yahtml-netscape-sentinel (proc mes) 1.41 (cond 1.42 @@ -1889,7 +1904,8 @@ 1.43 (let ((tag (yahtml-current-tag)) image (p (point)) (case-fold-search t)) 1.44 (if (and tag 1.45 (string-match "img" tag) 1.46 - (setq image (yahtml-get-attrvalue "src"))) 1.47 + (setq image 1.48 + (yahtml-unescape-string (yahtml-get-attrvalue "src")))) 1.49 (progn 1.50 (message "Invoking %s %s..." yahtml-image-viewer image) 1.51 (start-process 1.52 @@ -1903,7 +1919,7 @@ 1.53 (let ((env (yahtml-current-tag)) s (p (point))) 1.54 (cond 1.55 ((string-match "applet" env) 1.56 - (if (setq s (yahtml-get-attrvalue "code")) 1.57 + (if (setq s (yahtml-unescape-string (yahtml-get-attrvalue "code"))) 1.58 (progn 1.59 (setq s (YaTeX-match-string 1) 1.60 s (concat