unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] etc-dcc: Fix handling SEND commands with unquoted filename.
@ 2012-05-09 11:57 Mike Kazantsev
  2012-05-09 15:29 ` Michael Olson
  2012-05-14 15:43 ` Julien Danjou
  0 siblings, 2 replies; 3+ messages in thread
From: Mike Kazantsev @ 2012-05-09 11:57 UTC (permalink / raw)
  To: emacs-devel; +Cc: Julien Danjou, Michael Olson

[-- Attachment #1: Type: text/plain, Size: 2920 bytes --]

Good day,

Patch is a fix for a regression, which was introduced by the patch I
previously posted on this list (Date: Mon, 31 Oct 2011 09:56:58 +0600,
Subject: [PATCH] erc-dcc: allow SEND commands containing quoted
filenames with spaces in them).

As I see, it was picked up by Julien on Mon Nov 28 10:24:08 2011 +0100
in bb90806bc156833c (git://git.savannah.gnu.org/emacs.git).

Unfortunately, during one of the iterations of regexp-mangling, I
forgot to update match group number for *unquoted* filename matches,
thus introducing the regression.

Regexp in question is erc-dcc-ctcp-query-send-regexp and currently it
looks like this:

  (concat "^DCC SEND \\("
   ;; Following part matches either filename without spaces
   ;; or filename enclosed in double quotes with any number
   ;; of escaped double quotes inside.
   "\"\\(\\(.*?\\(\\\\\"\\)?\\)+?\\)\"\\|\\([^ ]+\\)"
   "\\) \\([0-9]+\\) \\([0-9]+\\) *\\([0-9]*\\)")

And the match is dissected like this:
 
  (let
    ((filename
      (or (match-string 3 query)
        (erc-dcc-unquote-filename (match-string 2 query))))
    (ip (erc-decimal-to-ip (match-string 6 query)))
    ...

As can be seen, though, unquoted filename is only matched by the fifth
regexp group ("|\\([^ ]+\\)" part), not third, thus matching of
unquoted filenames fails with non-descriptive nil-instead-of-string
error.

Issue was masked until now for me by custom (simplier hack)
erc-dcc-ctcp-query-send-regexp definition in my config, older emacs
version and relatively infrequent use of dcc with clients that don't
use filename-quoting.

Apologies to Julien and Michael for unasked-for CC, but I thought you
might be interested and should be notified, as people who reviewed the
initial patch.

Sorry for a lousy job of testing previous patch.
Thanks.


From e5fe5e71b0c7a898132dfce2a7ec72b8703079bd Mon Sep 17 00:00:00 2001
From: Mike Kazantsev <mk.fraggod@gmail.com>
Date: Wed, 9 May 2012 17:27:27 +0600
Subject: [PATCH] etc-dcc: Fix handling SEND commands with unquoted filename.

* erc-dcc.el (erc-dcc-handle-ctcp-send): Fix regexp match group numbers.

---
 lisp/erc/erc-dcc.el |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/erc/erc-dcc.el b/lisp/erc/erc-dcc.el
index ba87cf6..d1ef1a9 100644
--- a/lisp/erc/erc-dcc.el
+++ b/lisp/erc/erc-dcc.el
@@ -674,7 +674,7 @@ It extracts the information about the dcc request and adds it to
        ?r "SEND" ?n nick ?u login ?h host))
      ((string-match erc-dcc-ctcp-query-send-regexp query)
       (let ((filename
-             (or (match-string 3 query)
+             (or (match-string 5 query)
                  (erc-dcc-unquote-filename (match-string 2 query))))
             (ip       (erc-decimal-to-ip (match-string 6 query)))
             (port     (match-string 7 query))
-- 
1.7.10


-- 
Mike Kazantsev // fraggod.net

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] etc-dcc: Fix handling SEND commands with unquoted filename.
  2012-05-09 11:57 [PATCH] etc-dcc: Fix handling SEND commands with unquoted filename Mike Kazantsev
@ 2012-05-09 15:29 ` Michael Olson
  2012-05-14 15:43 ` Julien Danjou
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Olson @ 2012-05-09 15:29 UTC (permalink / raw)
  To: Mike Kazantsev; +Cc: Julien Danjou, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 3138 bytes --]

Explanation and patch make sense, +1 from me.

On Wed, May 9, 2012 at 4:57 AM, Mike Kazantsev <mk.fraggod@gmail.com> wrote:

> Good day,
>
> Patch is a fix for a regression, which was introduced by the patch I
> previously posted on this list (Date: Mon, 31 Oct 2011 09:56:58 +0600,
> Subject: [PATCH] erc-dcc: allow SEND commands containing quoted
> filenames with spaces in them).
>
> As I see, it was picked up by Julien on Mon Nov 28 10:24:08 2011 +0100
> in bb90806bc156833c (git://git.savannah.gnu.org/emacs.git).
>
> Unfortunately, during one of the iterations of regexp-mangling, I
> forgot to update match group number for *unquoted* filename matches,
> thus introducing the regression.
>
> Regexp in question is erc-dcc-ctcp-query-send-regexp and currently it
> looks like this:
>
>  (concat "^DCC SEND \\("
>   ;; Following part matches either filename without spaces
>   ;; or filename enclosed in double quotes with any number
>   ;; of escaped double quotes inside.
>   "\"\\(\\(.*?\\(\\\\\"\\)?\\)+?\\)\"\\|\\([^ ]+\\)"
>   "\\) \\([0-9]+\\) \\([0-9]+\\) *\\([0-9]*\\)")
>
> And the match is dissected like this:
>
>  (let
>    ((filename
>      (or (match-string 3 query)
>        (erc-dcc-unquote-filename (match-string 2 query))))
>    (ip (erc-decimal-to-ip (match-string 6 query)))
>    ...
>
> As can be seen, though, unquoted filename is only matched by the fifth
> regexp group ("|\\([^ ]+\\)" part), not third, thus matching of
> unquoted filenames fails with non-descriptive nil-instead-of-string
> error.
>
> Issue was masked until now for me by custom (simplier hack)
> erc-dcc-ctcp-query-send-regexp definition in my config, older emacs
> version and relatively infrequent use of dcc with clients that don't
> use filename-quoting.
>
> Apologies to Julien and Michael for unasked-for CC, but I thought you
> might be interested and should be notified, as people who reviewed the
> initial patch.
>
> Sorry for a lousy job of testing previous patch.
> Thanks.
>
>
> From e5fe5e71b0c7a898132dfce2a7ec72b8703079bd Mon Sep 17 00:00:00 2001
> From: Mike Kazantsev <mk.fraggod@gmail.com>
> Date: Wed, 9 May 2012 17:27:27 +0600
> Subject: [PATCH] etc-dcc: Fix handling SEND commands with unquoted
> filename.
>
> * erc-dcc.el (erc-dcc-handle-ctcp-send): Fix regexp match group numbers.
>
> ---
>  lisp/erc/erc-dcc.el |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lisp/erc/erc-dcc.el b/lisp/erc/erc-dcc.el
> index ba87cf6..d1ef1a9 100644
> --- a/lisp/erc/erc-dcc.el
> +++ b/lisp/erc/erc-dcc.el
> @@ -674,7 +674,7 @@ It extracts the information about the dcc request and
> adds it to
>        ?r "SEND" ?n nick ?u login ?h host))
>      ((string-match erc-dcc-ctcp-query-send-regexp query)
>       (let ((filename
> -             (or (match-string 3 query)
> +             (or (match-string 5 query)
>                  (erc-dcc-unquote-filename (match-string 2 query))))
>             (ip       (erc-decimal-to-ip (match-string 6 query)))
>             (port     (match-string 7 query))
> --
> 1.7.10
>
>
> --
> Mike Kazantsev // fraggod.net
>



-- 
Michael Olson  |  http://mwolson.org/

[-- Attachment #2: Type: text/html, Size: 4111 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] etc-dcc: Fix handling SEND commands with unquoted filename.
  2012-05-09 11:57 [PATCH] etc-dcc: Fix handling SEND commands with unquoted filename Mike Kazantsev
  2012-05-09 15:29 ` Michael Olson
@ 2012-05-14 15:43 ` Julien Danjou
  1 sibling, 0 replies; 3+ messages in thread
From: Julien Danjou @ 2012-05-14 15:43 UTC (permalink / raw)
  To: Mike Kazantsev; +Cc: Michael Olson, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 359 bytes --]

On Wed, May 09 2012, Mike Kazantsev wrote:

> Patch is a fix for a regression, which was introduced by the patch I
> previously posted on this list (Date: Mon, 31 Oct 2011 09:56:58 +0600,
> Subject: [PATCH] erc-dcc: allow SEND commands containing quoted
> filenames with spaces in them).

Thanks Mike, I've merged the patch.

-- 
           Julien

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-05-14 15:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-09 11:57 [PATCH] etc-dcc: Fix handling SEND commands with unquoted filename Mike Kazantsev
2012-05-09 15:29 ` Michael Olson
2012-05-14 15:43 ` Julien Danjou

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).