49 |
(regexp :value "^nntp\+.*:gmane\.")) |
(regexp :value "^nntp\+.*:gmane\.")) |
50 |
:group 'spam-report) |
:group 'spam-report) |
51 |
|
|
|
(defcustom spam-report-gmane-spam-header |
|
|
"^X-Report-Spam: http://\\([^/]+\\)\\(.*\\)$" |
|
|
"String matching Gmane spam-reporting header. Two match groups are needed." |
|
|
:type 'regexp |
|
|
:group 'spam-report) |
|
|
|
|
52 |
(defcustom spam-report-gmane-use-article-number t |
(defcustom spam-report-gmane-use-article-number t |
53 |
"Whether the article number (faster!) or the header should be used." |
"Whether the article number (faster!) or the header should be used." |
54 |
:type 'boolean |
:type 'boolean |
97 |
article)) |
article)) |
98 |
(with-current-buffer nntp-server-buffer |
(with-current-buffer nntp-server-buffer |
99 |
(gnus-request-head article gnus-newsgroup-name) |
(gnus-request-head article gnus-newsgroup-name) |
100 |
(goto-char (point-min)) |
(let ((case-fold-search t) |
101 |
(if (re-search-forward spam-report-gmane-spam-header nil t) |
field host report url) |
102 |
(let* ((host (match-string 1)) |
;; First check for X-Report-Spam because it's more specific to |
103 |
(report (match-string 2)) |
;; spam reporting than Archived-At. OTOH, all new articles on |
104 |
(url (format "http://%s%s" host report))) |
;; Gmane don't have X-Report-Spam anymore (unless Lars changes his |
105 |
(gnus-message 7 "Reporting spam through URL %s..." url) |
;; mind :-)). |
106 |
(spam-report-url-ping host report)) |
;; |
107 |
(gnus-message 3 "Could not find X-Report-Spam in article %d..." |
;; There might be more than one Archived-At header so we need to |
108 |
article))))))) |
;; find (and transform) the one related to Gmane. |
109 |
|
(setq field (or (gnus-fetch-field "X-Report-Spam") |
110 |
|
(gnus-fetch-field "Archived-At"))) |
111 |
|
(setq host (progn |
112 |
|
(string-match |
113 |
|
(concat "http://\\([a-z]+\\.gmane\\.org\\)" |
114 |
|
"\\(/[^:/]+[:/][0-9]+\\)") |
115 |
|
field) |
116 |
|
(match-string 1 field))) |
117 |
|
(setq report (match-string 2 field)) |
118 |
|
(when (string-equal "permalink.gmane.org" host) |
119 |
|
(setq host "spam.gmane.org")) |
120 |
|
(setq url (format "http://%s%s" host report)) |
121 |
|
(if (not (and host report url)) |
122 |
|
(gnus-message |
123 |
|
3 "Could not find a spam report header in article %d..." |
124 |
|
article) |
125 |
|
(gnus-message 7 "Reporting spam through URL %s..." url) |
126 |
|
(spam-report-url-ping host report)))))))) |
127 |
|
|
128 |
(defun spam-report-url-ping (host report) |
(defun spam-report-url-ping (host report) |
129 |
"Ping a host through HTTP, addressing a specific GET resource using |
"Ping a host through HTTP, addressing a specific GET resource using |
130 |
the function specified by `spam-report-url-ping-function'." |
the function specified by `spam-report-url-ping-function'." |
131 |
|
;; Example: |
132 |
|
;; host: "spam.gmane.org" |
133 |
|
;; report: "/gmane.some.group:123456" |
134 |
(funcall spam-report-url-ping-function host report)) |
(funcall spam-report-url-ping-function host report)) |
135 |
|
|
136 |
(defun spam-report-url-ping-plain (host report) |
(defun spam-report-url-ping-plain (host report) |