[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Link considered unsafe
From: |
Katsumi Yamaoka |
Subject: |
Re: Link considered unsafe |
Date: |
Mon, 10 Aug 2009 20:35:03 +0900 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/23.1.50 (gnu/linux) |
>>>>> Ted Zlatanov <tzz@lifelogs.com> wrote:
> On Tue, 04 Aug 2009 19:58:40 +0900 Katsumi Yamaoka <yamaoka@jpl.org> wrote:
KY> Maybe the groups can be controllable. For example:
KY> (defcustom mm-w3m-safe-groups "\\`nnrss[+:]"
KY> "Groups in which html articles are considered all safe.
KY> The value may be a regexp matching those groups, a list of group names,
KY> or nil. This overrides `mm-w3m-safe-url-regexp'.")
> I think that's reasonable. Looks like mm-decode.el and mm-view.el need
> to be modified. If no one else is interested I'll put it on my TODO list.
I thought making mm-*.el modules depend on Gnus (i.e., referring
to Gnus' variables like `gnus-newsgroup-name') is a wrong approach
because not only Gnus but also MH-E uses them. So I changed it
into the Gnus variable as follows:
(defcustom gnus-safe-html-groups "\\`nnrss[+:]"
"Groups in which links in html articles are considered all safe.
The value may be a regexp matching those groups, a list of group names,
or nil. This overrides `mm-w3m-safe-url-regexp' (which see). This is
effective only when emacs-w3m renders html articles, i.e., in the case
`mm-text-html-renderer' is set to `w3m'."
:version "23.2"
:group 'gnus-group-various
:type '(choice regexp
(repeat :tag "List of group names" (string :tag "Group"))
(const nil)))
The patch that uses it is below. There I made no change in mm-*.el
modules. What do you think about the option name and the macro name?
KY> BTW, don't all you know the way to access unsafe links? That is
KY> `C-u RET' on links in html articles.
> The problem is that calling the link "unsafe" scares the user.
> Furthermore, demanding different (RET vs C-u RET) keyboard actions from
> the user requires a mental context switch that distracts from the actual
> goal (visiting the link).
I see.
--- gnus-group.el~ 2009-07-10 11:55:43 +0000
+++ gnus-group.el 2009-08-10 11:31:28 +0000
@@ -110,6 +110,17 @@
:group 'gnus-group-listing
:type '(choice regexp (const nil)))
+(defcustom gnus-safe-html-groups "\\`nnrss[+:]"
+ "Groups in which links in html articles are considered all safe.
+The value may be a regexp matching those groups, a list of group names,
+or nil. This overrides `mm-w3m-safe-url-regexp' (which see). This is
+effective only when emacs-w3m renders html articles, i.e., in the case
+`mm-text-html-renderer' is set to `w3m'."
+ :group 'gnus-group-various
+ :type '(choice regexp
+ (repeat :tag "List of group names" (string :tag "Group"))
+ (const nil)))
+
(defcustom gnus-list-groups-with-ticked-articles t
"*If non-nil, list groups that have only ticked articles.
If nil, only list groups that have unread articles."
--- gnus-art.el~ 2009-07-23 23:54:28 +0000
+++ gnus-art.el 2009-08-10 11:31:28 +0000
@@ -4740,6 +4740,17 @@
(vector (caddr c) (car c) :active t))
gnus-mime-button-commands)))
+(defmacro gnus-bind-safe-url-regexp (&rest body)
+ "Bind `mm-w3m-safe-url-regexp' according to `gnus-safe-html-groups'."
+ `(let ((mm-w3m-safe-url-regexp
+ (if (cond ((stringp gnus-safe-html-groups)
+ (string-match gnus-safe-html-groups gnus-newsgroup-name))
+ ((consp gnus-safe-html-groups)
+ (member gnus-newsgroup-name gnus-safe-html-groups)))
+ nil
+ mm-w3m-safe-url-regexp)))
+ ,@body))
+
(defun gnus-mime-button-menu (event prefix)
"Construct a context-sensitive menu of MIME commands."
(interactive "e\nP")
@@ -4765,7 +4776,7 @@
(or (search-forward "\n\n") (goto-char (point-max)))
(let ((inhibit-read-only t))
(delete-region (point) (point-max))
- (mm-display-parts handles))))))
+ (gnus-bind-safe-url-regexp (mm-display-parts handles)))))))
(defun gnus-article-jump-to-part (n)
"Jump to MIME part N."
@@ -5267,7 +5278,7 @@
(when handle
(if (mm-handle-undisplayer handle)
(mm-remove-part handle)
- (mm-display-part handle))))))
+ (gnus-bind-safe-url-regexp (mm-display-part handle)))))))
(defun gnus-mime-action-on-part (&optional action)
"Do something with the MIME attachment at \(point\)."
@@ -5488,7 +5499,7 @@
(save-restriction
(narrow-to-region (point)
(if (eobp) (point) (1+ (point))))
- (mm-display-part handle)
+ (gnus-bind-safe-url-regexp (mm-display-part handle))
;; We narrow to the part itself and
;; then call the treatment functions.
(goto-char (point-min))
@@ -5767,7 +5778,7 @@
(set-buffer gnus-summary-buffer)
(error))
gnus-newsgroup-ignored-charsets)))
- (mm-display-part handle t))
+ (gnus-bind-safe-url-regexp (mm-display-part handle t)))
(goto-char (point-max)))
((and text not-attachment)
(when move
@@ -5903,7 +5914,7 @@
(mail-parse-ignored-charsets
(with-current-buffer gnus-summary-buffer
gnus-newsgroup-ignored-charsets)))
- (mm-display-part preferred)
+ (gnus-bind-safe-url-regexp (mm-display-part preferred))
;; Do highlighting.
(save-excursion
(save-restriction