diff --git a/lisp/gnus-logic.el b/lisp/gnus-logic.el index 954295438c953c2500b9c1959a49e52312cc9653..9216f5699ce1ed9a8c39dd03257a17885f6e8490 100644 --- a/lisp/gnus-logic.el +++ b/lisp/gnus-logic.el @@ -181,8 +181,10 @@ (with-current-buffer nntp-server-buffer (let* ((request-func (cond ((string= "head" header) 'gnus-request-head) + ;; We need to peek at the headers to detect the + ;; content encoding ((string= "body" header) - 'gnus-request-body) + 'gnus-request-article) (t 'gnus-request-article))) ofunc article) ;; Not all backends support partial fetching. In that case, we @@ -196,6 +198,20 @@ (gnus-message 7 "Scoring article %s..." article) (when (funcall request-func article gnus-newsgroup-name) (goto-char (point-min)) + ;; Searching base64/qp-encoded message body produces more + ;; satisfactory results if we decode the message first + (unless (or (eq ofunc 'gnus-request-head) + (eq request-func 'gnus-request-head)) + (let ((encoding (gnus-fetch-field "content-transfer-encoding"))) + (when encoding + (save-excursion + (save-restriction + ;; narrow to body + (narrow-to-region + (or (search-forward "\n\n" nil t) (point)) + (point-max)) + (mm-decode-content-transfer-encoding + (intern (downcase encoding)))))))) ;; If just parts of the article is to be searched and the ;; backend didn't support partial fetching, we just narrow to ;; the relevant parts. diff --git a/lisp/gnus-score.el b/lisp/gnus-score.el index f86b6f837a70ce54b06668187821fe57c3f80f4c..322aed78fa374b873fb8604482adead77362c5be 100644 --- a/lisp/gnus-score.el +++ b/lisp/gnus-score.el @@ -1752,8 +1752,10 @@ score in `gnus-newsgroup-scored' by SCORE." (all-scores scores) (request-func (cond ((string= "head" header) 'gnus-request-head) + ;; We need to peek at the headers to detect + ;; the content encoding ((string= "body" header) - 'gnus-request-body) + 'gnus-request-article) (t 'gnus-request-article))) entries alist ofunc article last) (when articles @@ -1773,6 +1775,20 @@ score in `gnus-newsgroup-scored' by SCORE." (widen) (when (funcall request-func article gnus-newsgroup-name) (goto-char (point-min)) + ;; Searching base64/qp-encoded message body produces more + ;; satisfactory results if we decode the message first + (unless (or (eq ofunc 'gnus-request-head) + (eq request-func 'gnus-request-head)) + (let ((encoding (gnus-fetch-field "content-transfer-encoding"))) + (when encoding + (save-excursion + (save-restriction + ;; narrow to body + (narrow-to-region + (or (search-forward "\n\n" nil t) (point)) + (point-max)) + (mm-decode-content-transfer-encoding + (intern (downcase encoding)))))))) ;; If just parts of the article is to be searched, but the ;; backend didn't support partial fetching, we just narrow ;; to the relevant parts.