[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r106538: erc-dcc: allow SEND commands
From: |
Julien Danjou |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r106538: erc-dcc: allow SEND commands containing quoted filenames with spaces in them |
Date: |
Mon, 28 Nov 2011 10:24:08 +0100 |
User-agent: |
Bazaar (2.3.1) |
------------------------------------------------------------
revno: 106538
committer: Julien Danjou <address@hidden>
branch nick: emacs-trunk
timestamp: Mon 2011-11-28 10:24:08 +0100
message:
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.
modified:
lisp/erc/ChangeLog
lisp/erc/erc-dcc.el
=== modified file 'lisp/erc/ChangeLog'
--- a/lisp/erc/ChangeLog 2011-11-20 03:48:53 +0000
+++ b/lisp/erc/ChangeLog 2011-11-28 09:24:08 +0000
@@ -1,3 +1,11 @@
+2011-11-28 Mike Kazantsev <address@hidden> (tiny change)
+
+ * 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.
+
2011-11-20 Juanma Barranquero <address@hidden>
* erc-log.el (erc-logging-enabled): Fix typo.
=== modified file 'lisp/erc/erc-dcc.el'
--- a/lisp/erc/erc-dcc.el 2011-04-26 13:50:09 +0000
+++ b/lisp/erc/erc-dcc.el 2011-11-28 09:24:08 +0000
@@ -649,7 +649,16 @@
?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.
@@ -664,10 +673,12 @@
'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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r106538: erc-dcc: allow SEND commands containing quoted filenames with spaces in them,
Julien Danjou <=