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: Sun, 30 Oct 2011 18:06:03 -0700

Looks good to me.  You may want to re-sent to the emacs-devel mailing
list and Cc: me, since they're effectively the maintainers of ERC now.

On Sun, Oct 30, 2011 at 1:46 AM, Mike Kazantsev <address@hidden> wrote:
> On Sat, 29 Oct 2011 23:41:44 -0700
> Michael Olson <address@hidden> wrote:
>
>> (But with backslashes instead of forward slashes in that example, of course)
>>
>> On Sat, Oct 29, 2011 at 11:41 PM, Michael Olson <address@hidden> wrote:
>> > Do you also need to unquote backslashes before doing anything with the
>> > filename?  E.g. // => /, /" => "
>> >
> ...
>
> Yes, I think that was a bug, too.
>
> Note that I also reordered regex groups here, so that any quoted
> filename will be processed through erc-dcc-unquote-filename.
>
> This contradicts pre-patch behavior somewhat in that now "file\"x" will
> be stored as file"x, not as-is (with enclosing quotes), but it seemed
> to be more consistent behavor for cases when clients use quoting w/o
> regard to the actual quoted contents.
>
>
>
> From b18c2639d53c2b87270ad21198cfe09a9b6a6684 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, added
>    processing of escaped quotes and backslashes if filename itself was
>    in quotes.
> ---
>  erc-dcc.el |   21 ++++++++++++++++-----
>  1 files changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/erc-dcc.el b/erc-dcc.el
> index 9e53edc..5aa346b 100644
> --- a/erc-dcc.el
> +++ b/erc-dcc.el
> @@ -646,7 +646,16 @@ 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]*\\)")
> +  (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]*\\)"))
> +
> +(defsubst erc-dcc-unquote-filename (filename)
> +  (erc-replace-regexp-in-string "\\\\\\\\" "\\"
> +    (erc-replace-regexp-in-string "\\\\\"" "\"" filename t t) t t))
>
>  (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 +670,12 @@ 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 3 query)
> +                  (erc-dcc-unquote-filename (match-string 2 query))))
> +            (ip       (erc-decimal-to-ip (match-string 6 query)))
> +            (port     (match-string 7 query))
> +            (size     (match-string 8 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]