[emacs-w3m:13583] w3m-safe-url-regexp
Hideyuki SHIRAI (白井秀行) <[email protected]> Sat, 11 Jan 2020 18:00:20 +0900 (JST)
| Newsgroups | gmane.emacs.w3m |
|---|---|
| Organization | Resident at Meadowy farm. |
| Message-ID | <[email protected]> |
こんにちは、白井です。 Mew のほうで、<img src="data:xxxx"> で埋め込まれている画像を表 示するにはどうするのですか?という話があり、 mew-w3m-safe-url-regexp "\\`cid:" となっているのを、 mew-w3m-safe-url-regexp "\\`\\(cid\\|data\\):" とするだけかな? と思いやってみました。 ## https://groups.google.com/d/msgid/mew-ja/467DC098-3A95-40A5-960A-183492B7D717%40beaupix.com が、上記のようにすると通常の <img src="http://xxxx"> も表示され るようになりダメダメでした。 で、追いかけたのですが、 w3m-region() → w3m-fontify() で 'w3m-safe-url-regexp 全面埋め込み → point-max() で (insert "\n") → w3m-toggle-inline-images() w3m-toggle-inline-images() は (insert "\n") の後ろで、 (setq safe-regexp (get-text-property (point) 'w3m-safe-url-regexp)) していて、そこには w3m-safe-url-regexp の property が付いていな いから、ということがわかりました。rear-nonsticky? なので、上記のチェックを (point-min) でやるように (setq safe-regexp (get-text-property beg 'w3m-safe-url-regexp)) と変更すると期待通りに動きました (なぜ、cid だけだとうまく動作 していたのか、今となっては不明)。 また、beg で絶対大丈夫か?は、今一わかっていません。 ## 最近、ごぶさたなので、なにか大嘘をやっているかも github の使い方相変わらずわかっていないので、mew-w3m.el も含めて パッチ送ります m(_ _)m
shirai.diff
(text/x-patch, 1.4 KB)
diff --git a/mew-w3m.el b/mew-w3m.el
index 5384ea73..8822c0bd 100644
--- a/mew-w3m.el
+++ b/mew-w3m.el
@@ -111,7 +111,17 @@ Text/Html contents."
(const :tag "Use Cite Mark \"> \"" "> ")
(string :tag "Use Other Mark")))
-(defconst mew-w3m-safe-url-regexp "\\`cid:")
+(defcustom mew-w3m-safe-url-regexp "\\`\\(cid\\|data\\):"
+ "Regexp that matches safe url names.
+Some HTML mails might have the trick of spammers using <img> tags. It
+is likely to be intended to verify whether you have read the mail.
+You can prevent your personal informations from leaking by setting
+this to the regexp which matches the safe url names. The value of the
+variable `w3m-safe-url-regexp' will be bound with this value. You may
+set this value to nil if you consider all the urls to be safe."
+ :group 'mime-w3m
+ :type '(choice (regexp :format "%t: %v")
+ (const :tag "All URLs are safe" nil)))
;; Avoid bytecompile errors and warnings.
(defvar mew-use-text/html)
diff --git a/w3m.el b/w3m.el
index 1b068f33..c513a7ba 100644
--- a/w3m.el
+++ b/w3m.el
@@ -4050,7 +4050,7 @@ variable is non-nil (default=t)."
(setq beg (point-min)
end (point-max)))
(unless status
- (when (setq safe-regexp (get-text-property (point) 'w3m-safe-url-regexp))
+ (when (setq safe-regexp (get-text-property beg 'w3m-safe-url-regexp))
;; Scan the buffer for searching for an insecure image url.
(setq pos beg)
(setq