erc-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Erc-discuss] [PATCH] erc-dcc: allow SEND commands containing quoted


From: Michael Olson
Subject: Re: [Erc-discuss] [PATCH] erc-dcc: allow SEND commands containing quoted filenames with spaces in them
Date: Sat, 29 Oct 2011 12:08:01 -0700

Be careful with that regexp.  It's not going to be able to handle
escaped quotes (with backslash, presumably).  I'd rather have it be
flawless before checking in, unless it's IRC convention to not parse
that kind of thing.  Also, <<.*+?>> is not very meaningful -- perhaps
you meant <<.*?>> ?

On Fri, Oct 28, 2011 at 11:04 PM, Mike Kazantsev <address@hidden> wrote:
> Good day,
>
> This patch allows receiving DCC SEND requests like these (X'es in IP
> are digits):
>
>  DCC SEND "Jim C. Hines - Jig the Goblin - 2 - Goblin Hero (RB v1.0).epub" 
> 34732XXXXX 3746 322641
>
> Filename here is enclosed in double quotes, which seem to be a common
> IRC client (and dcc bot) convention for names with whitespaces and is
> widely used in file-sharing channels.
>
> Filenames without whitespace in them are not stripped of double quotes,
> consistent with previous versions.
>
> Change is basically matching ([^ ]+)|"(.*+?)" for filename instead of
> just ([^ ]+).
> Only one possible issue I can see with it is if filename *starts* with
> double quote character and this character is used in some other field X,
> *and* the overall field number in "number of field X" + 3 or greater.
>
> I've never encountered such usage, and believe it's much more useful to
> support the most common DCC SEND usage than these exotic cases if
> indeed they exist at all.
> Otherwise, I guess some option can be added to support such
> quoted-filenames, but again, I don't think it's worth the complexity
> and should be default behavior anyway.
>
> Thanks!
>
>
> From 3198d78525afadfbca7b33fd6168c1aba9bad205 Mon Sep 17 00:00:00 2001
> From: Mike Kazantsev <address@hidden>
> Date: Sat, 29 Oct 2011 11:36:49 +0600
> Subject: [PATCH] erc-dcc: allow SEND commands containing quoted filenames
>  with spaces in them
>
> * erc-dcc.el (erc-dcc-ctcp-query-send-regexp): Updated regexp to match
>    quoted filenames with spaces inside.
>  (erc-dcc-handle-ctcp-send): Updated regexp match group numbers.
> ---
>  erc-dcc.el |   11 ++++++-----
>  1 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/erc-dcc.el b/erc-dcc.el
> index 9e53edc..95b3d17 100644
> --- a/erc-dcc.el
> +++ b/erc-dcc.el
> @@ -646,7 +646,7 @@ that subcommand."
>        ?q query ?n nick ?u login ?h host))))
>
>  (defconst erc-dcc-ctcp-query-send-regexp
> -  "^DCC SEND \\([^ ]+\\) \\([0-9]+\\) \\([0-9]+\\) *\\([0-9]*\\)")
> +  "^DCC SEND \\(\\([^ ]+\\)\\|\"\\(.*+?\\)\"\\) \\([0-9]+\\) \\([0-9]+\\) 
> *\\([0-9]*\\)")
>
>  (defun erc-dcc-handle-ctcp-send (proc query nick login host to)
>   "This is called if a CTCP DCC SEND subcommand is sent to the client.
> @@ -661,10 +661,11 @@ It extracts the information about the dcc request and 
> adds it to
>        'dcc-request-bogus
>        ?r "SEND" ?n nick ?u login ?h host))
>      ((string-match erc-dcc-ctcp-query-send-regexp query)
> -      (let ((filename (match-string 1 query))
> -            (ip       (erc-decimal-to-ip (match-string 2 query)))
> -            (port     (match-string 3 query))
> -            (size     (match-string 4 query)))
> +      (let ((filename
> +              (or (match-string 2 query) (match-string 3 query)))
> +            (ip       (erc-decimal-to-ip (match-string 4 query)))
> +            (port     (match-string 5 query))
> +            (size     (match-string 6 query)))
>         ;; FIXME: a warning really should also be sent
>         ;; if the ip address != the host the dcc sender is on.
>         (erc-display-message
> --
> 1.7.7
>
>
> --
> Mike Kazantsev // fraggod.net
>
> _______________________________________________
> Erc-discuss mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/erc-discuss
>
>



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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]