* Re: [Emacs-diffs] master 7466a4d: Cygwin emacsclient handles w32 file names
[not found] ` <E1Z9jtU-0001Tx-85@vcs.savannah.gnu.org>
@ 2015-06-30 2:40 ` Ken Brown
2015-06-30 13:56 ` Stefan Monnier
2015-07-01 14:14 ` Ken Brown
0 siblings, 2 replies; 10+ messages in thread
From: Ken Brown @ 2015-06-30 2:40 UTC (permalink / raw)
To: emacs-devel, Michael R. Mauger
On 6/29/2015 8:59 PM, Michael Mauger wrote:
> branch: master
> commit 7466a4ded6ded0bea50151395b7a0fccc5dfd167
> Author: Michael R. Mauger <michael@mauger.com>
> Commit: Michael R. Mauger <michael@mauger.com>
>
> Cygwin emacsclient handles w32 file names
> ---
> lisp/server.el | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/lisp/server.el b/lisp/server.el
> index 2007635..ce19b3c 100644
> --- a/lisp/server.el
> +++ b/lisp/server.el
> @@ -1167,6 +1167,9 @@ The following commands are accepted by the client:
> (let ((file (pop args-left)))
> (if coding-system
> (setq file (decode-coding-string file coding-system)))
> + (when (and (eq system-type 'cygwin)
> + (fboundp 'cygwin-convert-file-name-from-windows))
There's no need for the 'fboundp ...' here;
cygwin-convert-file-name-from-windows is defined in all Cygwin builds.
> + (setq file (cygwin-convert-file-name-from-windows file)))
> (setq file (expand-file-name file dir))
> (push (cons file filepos) files)
> (server-log (format "New file: %s %s"
Are you sure that emacsclient will still handle ordinary Cygwin file
names properly after this change? I'm concerned about file names that
contain characters from the (default) UTF-8 character set. I'm not very
familiar with exactly how cygwin-convert-file-name-from-windows works,
but its name suggests that it should be given a file name that's
understood by Windows.
Ken
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Emacs-diffs] master 7466a4d: Cygwin emacsclient handles w32 file names
2015-06-30 2:40 ` [Emacs-diffs] master 7466a4d: Cygwin emacsclient handles w32 file names Ken Brown
@ 2015-06-30 13:56 ` Stefan Monnier
2015-07-01 14:14 ` Ken Brown
1 sibling, 0 replies; 10+ messages in thread
From: Stefan Monnier @ 2015-06-30 13:56 UTC (permalink / raw)
To: Ken Brown; +Cc: Michael R. Mauger, emacs-devel
>> + (when (and (eq system-type 'cygwin)
>> + (fboundp 'cygwin-convert-file-name-from-windows))
> There's no need for the 'fboundp ...' here;
> cygwin-convert-file-name-from-windows is defined in all Cygwin builds.
I'm not arguing for or against this test, but I'm just pointing out that
the test should have the benefit of silencing the byte-compiler when
compiling on a non-Cygwin machine.
Stefan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Emacs-diffs] master 7466a4d: Cygwin emacsclient handles w32 file names
2015-06-30 2:40 ` [Emacs-diffs] master 7466a4d: Cygwin emacsclient handles w32 file names Ken Brown
2015-06-30 13:56 ` Stefan Monnier
@ 2015-07-01 14:14 ` Ken Brown
2015-07-01 15:47 ` Eli Zaretskii
2015-07-02 2:28 ` Michael Mauger
1 sibling, 2 replies; 10+ messages in thread
From: Ken Brown @ 2015-07-01 14:14 UTC (permalink / raw)
To: Michael R. Mauger; +Cc: emacs-devel
On 6/29/2015 10:40 PM, Ken Brown wrote:
> On 6/29/2015 8:59 PM, Michael Mauger wrote:
>> branch: master
>> commit 7466a4ded6ded0bea50151395b7a0fccc5dfd167
>> Author: Michael R. Mauger <michael@mauger.com>
>> Commit: Michael R. Mauger <michael@mauger.com>
>>
>> Cygwin emacsclient handles w32 file names
>> ---
>> lisp/server.el | 3 +++
>> 1 files changed, 3 insertions(+), 0 deletions(-)
>>
>> diff --git a/lisp/server.el b/lisp/server.el
>> index 2007635..ce19b3c 100644
>> --- a/lisp/server.el
>> +++ b/lisp/server.el
>> @@ -1167,6 +1167,9 @@ The following commands are accepted by the client:
>> (let ((file (pop args-left)))
>> (if coding-system
>> (setq file (decode-coding-string file
>> coding-system)))
>> + (when (and (eq system-type 'cygwin)
>> + (fboundp
>> 'cygwin-convert-file-name-from-windows))
>
> There's no need for the 'fboundp ...' here;
> cygwin-convert-file-name-from-windows is defined in all Cygwin builds.
>
>> + (setq file
>> (cygwin-convert-file-name-from-windows file)))
>> (setq file (expand-file-name file dir))
>> (push (cons file filepos) files)
>> (server-log (format "New file: %s %s"
>
> Are you sure that emacsclient will still handle ordinary Cygwin file
> names properly after this change? I'm concerned about file names that
> contain characters from the (default) UTF-8 character set. I'm not very
> familiar with exactly how cygwin-convert-file-name-from-windows works,
> but its name suggests that it should be given a file name that's
> understood by Windows.
I've tested this a little with file names containing UTF-8-encoded
Chinese and other non-ASCII characters, and it appears to work OK. But
I *think* it only works because of accidental implementation details of
cygwin-convert-file-name-from-windows (and the underlying Cygwin
function cygwin_conv_path). Basically, it seems that these functions
don't actually try to do any conversion if they are given a multibyte
string instead of the expected UTF-16 string.
So even though this change *might* be harmless, I think it could lead to
bugs later if implementations change. I don't think
cygwin-convert-file-name-from-windows should be called on a file name
that is not known to be a (UTF-16-encoded) Windows file name. If you
look at the (very few) places in the emacs code where that function is
currently called, you'll see that the argument is indeed known to be a
Windows file name.
Ken
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Emacs-diffs] master 7466a4d: Cygwin emacsclient handles w32 file names
2015-07-01 14:14 ` Ken Brown
@ 2015-07-01 15:47 ` Eli Zaretskii
2015-07-02 2:28 ` Michael Mauger
1 sibling, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2015-07-01 15:47 UTC (permalink / raw)
To: Ken Brown; +Cc: michael, emacs-devel
> Date: Wed, 01 Jul 2015 10:14:20 -0400
> From: Ken Brown <kbrown@cornell.edu>
> Cc: emacs-devel@gnu.org
>
> I've tested this a little with file names containing UTF-8-encoded
> Chinese and other non-ASCII characters, and it appears to work OK. But
> I *think* it only works because of accidental implementation details of
> cygwin-convert-file-name-from-windows (and the underlying Cygwin
> function cygwin_conv_path). Basically, it seems that these functions
> don't actually try to do any conversion if they are given a multibyte
> string instead of the expected UTF-16 string.
That was also my conclusion.
> So even though this change *might* be harmless, I think it could lead to
> bugs later if implementations change. I don't think
> cygwin-convert-file-name-from-windows should be called on a file name
> that is not known to be a (UTF-16-encoded) Windows file name.
The UTF-16 encoding is not an issue, because
cygwin-convert-file-name-from-windows calls to_unicode to ensure that.
I think this code needs to look at the result of expand-file-name for
the file and the default directory in effect, and check whether the
result begins with a drive letter. If it does, it should call
cygwin-convert-file-name-from-windows.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Emacs-diffs] master 7466a4d: Cygwin emacsclient handles w32 file names
2015-07-01 14:14 ` Ken Brown
2015-07-01 15:47 ` Eli Zaretskii
@ 2015-07-02 2:28 ` Michael Mauger
2015-07-02 19:48 ` Ken Brown
1 sibling, 1 reply; 10+ messages in thread
From: Michael Mauger @ 2015-07-02 2:28 UTC (permalink / raw)
To: Ken Brown; +Cc: emacs-devel@gnu.org
On Wednesday, July 1, 2015 10:14 AM, Ken Brown <kbrown@cornell.edu> wrte:
>
>
>On 6/29/2015 10:40 PM, Ken Brown wrote:
>> On 6/29/2015 8:59 PM, Michael Mauger wrote:
>>> branch: master
>>> commit 7466a4ded6ded0bea50151395b7a0fccc5dfd167
>>> Author: Michael R. Mauger <michael@mauger.com>
>>> Commit: Michael R. Mauger <michael@mauger.com>
>>>
>>> Cygwin emacsclient handles w32 file names
>>> ---
>>> lisp/server.el | 3 +++
>>> 1 files changed, 3 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/lisp/server.el b/lisp/server.el
>>> index 2007635..ce19b3c 100644
>>> --- a/lisp/server.el
>>> +++ b/lisp/server.el
>>> @@ -1167,6 +1167,9 @@ The following commands are accepted by the client:
>>> (let ((file (pop args-left)))
>>> (if coding-system
>>> (setq file (decode-coding-string file
>>> coding-system)))
>>> + (when (and (eq system-type 'cygwin)
>>> + (fboundp
>>> 'cygwin-convert-file-name-from-windows))
>>
>> There's no need for the 'fboundp ...' here;
>> cygwin-convert-file-name-from-windows is defined in all Cygwin builds.
>>
>>> + (setq file
>>> (cygwin-convert-file-name-from-windows file)))
>>> (setq file (expand-file-name file dir))
>>> (push (cons file filepos) files)
>>> (server-log (format "New file: %s %s"
>>
>> Are you sure that emacsclient will still handle ordinary Cygwin file
>> names properly after this change? I'm concerned about file names that
>> contain characters from the (default) UTF-8 character set. I'm not very
>> familiar with exactly how cygwin-convert-file-name-from-windows works,
>> but its name suggests that it should be given a file name that's
>> understood by Windows.
>
>I've tested this a little with file names containing UTF-8-encoded
>Chinese and other non-ASCII characters, and it appears to work OK. But
>I *think* it only works because of accidental implementation details of
>cygwin-convert-file-name-from-windows (and the underlying Cygwin
>function cygwin_conv_path). Basically, it seems that these functions
>don't actually try to do any conversion if they are given a multibyte
>string instead of the expected UTF-16 string.
>
>So even though this change *might* be harmless, I think it could lead to
>bugs later if implementations change. I don't think
>cygwin-convert-file-name-from-windows should be called on a file name
>that is not known to be a (UTF-16-encoded) Windows file name. If you
>look at the (very few) places in the emacs code where that function is
>currently called, you'll see that the argument is indeed known to be a
>Windows file name.
>
>Ken
>
While I think there may be legit concerns about the character encoding,
the entire Cygwin environment is susceptible to such problems so I do
not think it is a risky new exposure. What this enables is to use the
cygwin'ified emacsclient to be used as a file handler under MSWindows.
MSWindows passes the full file path to the emacsclient process and this
will translate the file name to the equivalent cygwin path. Passing a
cygwin file name through this function seems to return the file name
unmolested so it doesn't require a lot of guarding for file name syntax
before calling it (But I will defer to Ken who knows the internal
workings of cygwin far better than I).
I use the above version of the patch on both cygwin and GNU/Linux ports
of Emacs daily.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Emacs-diffs] master 7466a4d: Cygwin emacsclient handles w32 file names
2015-07-02 2:28 ` Michael Mauger
@ 2015-07-02 19:48 ` Ken Brown
2015-07-04 15:20 ` Ken Brown
0 siblings, 1 reply; 10+ messages in thread
From: Ken Brown @ 2015-07-02 19:48 UTC (permalink / raw)
To: Michael Mauger; +Cc: emacs-devel@gnu.org
On 7/1/2015 10:28 PM, Michael Mauger wrote:
>
> On Wednesday, July 1, 2015 10:14 AM, Ken Brown <kbrown@cornell.edu> wrte:
>
>>
>>
>> On 6/29/2015 10:40 PM, Ken Brown wrote:
>>> On 6/29/2015 8:59 PM, Michael Mauger wrote:
>>>> branch: master
>>>> commit 7466a4ded6ded0bea50151395b7a0fccc5dfd167
>>>> Author: Michael R. Mauger <michael@mauger.com>
>>>> Commit: Michael R. Mauger <michael@mauger.com>
>>>>
>>>> Cygwin emacsclient handles w32 file names
>>>> ---
>>>> lisp/server.el | 3 +++
>>>> 1 files changed, 3 insertions(+), 0 deletions(-)
>>>>
>>>> diff --git a/lisp/server.el b/lisp/server.el
>>>> index 2007635..ce19b3c 100644
>>>> --- a/lisp/server.el
>>>> +++ b/lisp/server.el
>>>> @@ -1167,6 +1167,9 @@ The following commands are accepted by the client:
>>>> (let ((file (pop args-left)))
>>>> (if coding-system
>>>> (setq file (decode-coding-string file
>>>> coding-system)))
>>>> + (when (and (eq system-type 'cygwin)
>>>> + (fboundp
>>>> 'cygwin-convert-file-name-from-windows))
>>>
>>> There's no need for the 'fboundp ...' here;
>>> cygwin-convert-file-name-from-windows is defined in all Cygwin builds.
>>>
>>>> + (setq file
>>>> (cygwin-convert-file-name-from-windows file)))
>>>> (setq file (expand-file-name file dir))
>>>> (push (cons file filepos) files)
>>>> (server-log (format "New file: %s %s"
>>>
>>> Are you sure that emacsclient will still handle ordinary Cygwin file
>>> names properly after this change? I'm concerned about file names that
>>> contain characters from the (default) UTF-8 character set. I'm not very
>>> familiar with exactly how cygwin-convert-file-name-from-windows works,
>>> but its name suggests that it should be given a file name that's
>>> understood by Windows.
>>
>> I've tested this a little with file names containing UTF-8-encoded
>> Chinese and other non-ASCII characters, and it appears to work OK. But
>> I *think* it only works because of accidental implementation details of
>> cygwin-convert-file-name-from-windows (and the underlying Cygwin
>> function cygwin_conv_path). Basically, it seems that these functions
>> don't actually try to do any conversion if they are given a multibyte
>> string instead of the expected UTF-16 string.
>>
>> So even though this change *might* be harmless, I think it could lead to
>> bugs later if implementations change. I don't think
>> cygwin-convert-file-name-from-windows should be called on a file name
>> that is not known to be a (UTF-16-encoded) Windows file name. If you
>> look at the (very few) places in the emacs code where that function is
>> currently called, you'll see that the argument is indeed known to be a
>> Windows file name.
>>
>> Ken
>>
>
>
> While I think there may be legit concerns about the character encoding,
>
> the entire Cygwin environment is susceptible to such problems so I do
>
> not think it is a risky new exposure. What this enables is to use the
> cygwin'ified emacsclient to be used as a file handler under MSWindows.
>
> MSWindows passes the full file path to the emacsclient process and this
> will translate the file name to the equivalent cygwin path. Passing a
>
> cygwin file name through this function seems to return the file name
>
> unmolested so it doesn't require a lot of guarding for file name syntax
> before calling it (But I will defer to Ken who knows the internal
>
> workings of cygwin far better than I).
It's not a question of knowing the internal workings of Cygwin. My point is
that the code should be made to be clearly correct, without any knowledge of the
internals of Cygwin and without any undocumented knowledge of how
cygwin-convert-file-name-from-windows is implemented. Even though the latter
appears to return a Cygwin file name unmolested, its documentation says only
"Convert a Windows-style file name FILE to a Cygwin file name".
So I would be much more comfortable with this change if you added a check for a
file name starting with a drive letter. And it might also be good to add a
comment explaining the intended use, in which Windows passes a full file path to
emacsclient.
Ken
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Emacs-diffs] master 7466a4d: Cygwin emacsclient handles w32 file names
2015-07-02 19:48 ` Ken Brown
@ 2015-07-04 15:20 ` Ken Brown
2015-07-04 18:29 ` Stefan Monnier
2015-07-07 14:36 ` Ken Brown
0 siblings, 2 replies; 10+ messages in thread
From: Ken Brown @ 2015-07-04 15:20 UTC (permalink / raw)
To: Michael Mauger; +Cc: emacs-devel@gnu.org
On 7/2/2015 3:48 PM, Ken Brown wrote:
> So I would be much more comfortable with this change if you added a check for a
> file name starting with a drive letter. And it might also be good to add a
> comment explaining the intended use, in which Windows passes a full file path to
> emacsclient.
Something like the following is what I had in mind:
diff --git a/lisp/server.el b/lisp/server.el
index ce19b3c..46687a3 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -1167,8 +1167,11 @@ The following commands are accepted by the client:
(let ((file (pop args-left)))
(if coding-system
(setq file (decode-coding-string file coding-system)))
+ ;; Allow Cygwin's emacsclient to be used as a file
+ ;; handler on MS-Windows, in which case FILENAME
+ ;; might start with a drive letter.
(when (and (eq system-type 'cygwin)
- (fboundp 'cygwin-convert-file-name-from-windows))
+ (string-match "^[A-Za-z]:" file))
(setq file (cygwin-convert-file-name-from-windows file)))
(setq file (expand-file-name file dir))
(push (cons file filepos) files)
Ken
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Emacs-diffs] master 7466a4d: Cygwin emacsclient handles w32 file names
2015-07-04 15:20 ` Ken Brown
@ 2015-07-04 18:29 ` Stefan Monnier
2015-07-04 19:05 ` Ken Brown
2015-07-07 14:36 ` Ken Brown
1 sibling, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2015-07-04 18:29 UTC (permalink / raw)
To: Ken Brown; +Cc: Michael Mauger, emacs-devel@gnu.org
> + (string-match "^[A-Za-z]:" file))
^^^
You mean \\`
Stefan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Emacs-diffs] master 7466a4d: Cygwin emacsclient handles w32 file names
2015-07-04 18:29 ` Stefan Monnier
@ 2015-07-04 19:05 ` Ken Brown
0 siblings, 0 replies; 10+ messages in thread
From: Ken Brown @ 2015-07-04 19:05 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Michael Mauger, emacs-devel@gnu.org
On 7/4/2015 2:29 PM, Stefan Monnier wrote:
>> + (string-match "^[A-Za-z]:" file))
> ^^^
> You mean \\`
Now that I've re-read the documentation about regexps, yes, that's what I mean.
Somehow I never noticed the difference between ^ and \` before. Thanks.
Ken
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Emacs-diffs] master 7466a4d: Cygwin emacsclient handles w32 file names
2015-07-04 15:20 ` Ken Brown
2015-07-04 18:29 ` Stefan Monnier
@ 2015-07-07 14:36 ` Ken Brown
1 sibling, 0 replies; 10+ messages in thread
From: Ken Brown @ 2015-07-07 14:36 UTC (permalink / raw)
To: Michael Mauger; +Cc: emacs-devel@gnu.org
On 7/4/2015 11:20 AM, Ken Brown wrote:
> diff --git a/lisp/server.el b/lisp/server.el
> index ce19b3c..46687a3 100644
> --- a/lisp/server.el
> +++ b/lisp/server.el
> @@ -1167,8 +1167,11 @@ The following commands are accepted by the client:
> (let ((file (pop args-left)))
> (if coding-system
> (setq file (decode-coding-string file
> coding-system)))
> + ;; Allow Cygwin's emacsclient to be used as a file
> + ;; handler on MS-Windows, in which case FILENAME
> + ;; might start with a drive letter.
> (when (and (eq system-type 'cygwin)
> - (fboundp
> 'cygwin-convert-file-name-from-windows))
> + (string-match "^[A-Za-z]:" file))
> (setq file (cygwin-convert-file-name-from-windows
> file)))
> (setq file (expand-file-name file dir))
> (push (cons file filepos) files)
I've pushed this change (with Stefan's correction) as git commit b25770a.
Ken
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-07-07 14:36 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20150630005924.5663.80677@vcs.savannah.gnu.org>
[not found] ` <E1Z9jtU-0001Tx-85@vcs.savannah.gnu.org>
2015-06-30 2:40 ` [Emacs-diffs] master 7466a4d: Cygwin emacsclient handles w32 file names Ken Brown
2015-06-30 13:56 ` Stefan Monnier
2015-07-01 14:14 ` Ken Brown
2015-07-01 15:47 ` Eli Zaretskii
2015-07-02 2:28 ` Michael Mauger
2015-07-02 19:48 ` Ken Brown
2015-07-04 15:20 ` Ken Brown
2015-07-04 18:29 ` Stefan Monnier
2015-07-04 19:05 ` Ken Brown
2015-07-07 14:36 ` Ken Brown
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).