unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Victor Orlikowski <vjo@duke.edu>
To: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: [PATCH] Fixes to allow erc-dcc-get-filter to work properly
Date: Sun, 3 Feb 2019 17:47:16 +0000	[thread overview]
Message-ID: <CD36F2CB-49E3-4441-AEAF-DD6B62B1CF13.notmuch@neverland> (raw)

When using erc-dcc-get-filter with erc-dcc-verbose set to t, message
errors prevent the DCC get from completing correctly.

The attached patch adds some additional error checking to
erc-dcc-get-filter, and uses erc-dcc-file-name in place of
buffer-file-name (which ends up being nil in this context, and
causing the message errors).

From 22bbaa226ad0550f566b4d2978e0aea4c72f82a1 Mon Sep 17 00:00:00 2001
From: "Victor J. Orlikowski" <vjo@duke.edu>
Date: Sun, 3 Feb 2019 12:36:26 -0500
Subject: [PATCH] Perform additional validation in erc-dcc-get-filter, and use
 erc-dcc-file-name rather than buffer-file-name (which is actually nil in this
 context).

---
 lisp/erc/erc-dcc.el | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lisp/erc/erc-dcc.el b/lisp/erc/erc-dcc.el
index 8a40b1454b..842a3b2b19 100644
--- a/lisp/erc/erc-dcc.el
+++ b/lisp/erc/erc-dcc.el
@@ -979,17 +979,20 @@ rather than every 1024 byte block, but nobody seems to care."
     (let ((inhibit-read-only t)
           received-bytes)
       (goto-char (point-max))
-      (insert (string-make-unibyte str))
+      (if str
+          (insert (string-make-unibyte str)))
 
       (when (> (point-max) erc-dcc-receive-cache)
         (erc-dcc-append-contents (current-buffer) erc-dcc-file-name))
-      (setq received-bytes (+ (buffer-size) erc-dcc-byte-count))
+      (setq received-bytes (buffer-size))
+      (if erc-dcc-byte-count
+          (setq received-bytes (+ received-bytes erc-dcc-byte-count)))
 
       (and erc-dcc-verbose
            (erc-display-message
             nil 'notice erc-server-process
             'dcc-get-bytes-received
-            ?f (file-name-nondirectory buffer-file-name)
+            ?f (file-name-nondirectory erc-dcc-file-name)
             ?b (number-to-string received-bytes)))
       (cond
        ((and (> (plist-get erc-dcc-entry-data :size) 0)
@@ -997,7 +1000,7 @@ rather than every 1024 byte block, but nobody seems to care."
         (erc-display-message
          nil '(notice error) 'active
          'dcc-get-file-too-long
-         ?f (file-name-nondirectory buffer-file-name))
+         ?f (file-name-nondirectory erc-dcc-file-name))
         (delete-process proc))
        (t
         (process-send-string
-- 
2.20.0

Best,
Victor
-- 
Victor J. Orlikowski <> vjo@(ee.|cs.)?duke.edu



             reply	other threads:[~2019-02-03 17:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-03 17:47 Victor Orlikowski [this message]
2019-02-08  7:59 ` [PATCH] Fixes to allow erc-dcc-get-filter to work properly Eli Zaretskii
2019-02-08 22:00   ` Victor Orlikowski
2019-02-09  9:49     ` Eli Zaretskii
2019-02-10 16:07       ` Victor Orlikowski
2019-02-10 16:41         ` Eli Zaretskii
2019-02-10 19:02           ` Victor Orlikowski
2019-02-10 19:14 ` [PATCH] v2: " Victor Orlikowski
2019-02-15  8:18   ` Eli Zaretskii
2019-02-17 18:57     ` Victor Orlikowski
2019-02-17 19:32       ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CD36F2CB-49E3-4441-AEAF-DD6B62B1CF13.notmuch@neverland \
    --to=vjo@duke.edu \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).