Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if utf8 filename #124

Closed
yanmingsohu opened this issue Aug 13, 2015 · 5 comments
Closed

if utf8 filename #124

yanmingsohu opened this issue Aug 13, 2015 · 5 comments

Comments

@yanmingsohu
Copy link

modify 434: var sockerr, done = false, replies = 0, entries, buffer = [], source = sock;
modify 441: source.on('data', function(chunk) { buffer.push(chunk); });
insert 455: buffer = Buffer.concat(buffer).toString();

@AyrA
Copy link

AyrA commented Aug 13, 2015

This did not fix the problem for me. When I retrieve a directory listing on my server, chars like äöü are messed up. They seem to be encoded twice. I have tried the ascii option but this does not helps.

It looks like data over a PASV connection is always treated as binary, but some commands, like CWD,PWD and LIST should be treated as UTF-8 text. Modern FTP Servers (for example FileZilla Server) have UTF-8 always on and it cannot be turned off (OPTS utf8 OFF)

@mscdex
Copy link
Owner

mscdex commented Aug 13, 2015

I'd be open to a PR that checks for the UTF-8 feature (enabling it if possible) and then using UTF-8 encoding for non-file transfers if said feature is available. The binary usage was originally there because some servers were using other encodings and converting them to ascii/utf8 would cause the text to be mangled.

@AyrA
Copy link

AyrA commented Aug 13, 2015

@mscdex A server announces this feature in the FEAT command:

FEAT
211-Features:
MDTM
REST STREAM
SIZE
MODE Z
MLST type*;size*;modify*;
MLSD
AUTH SSL
AUTH TLS
PROT
PBSZ
UTF8 <-- This
CLNT
MFMT
211 End

@AyrA
Copy link

AyrA commented Aug 13, 2015

The solution from @yanmingsohu has worked in the end. I was piping the output directly to the http component (to make a http frontend for ftp if somebody is interested) where it got mangled. I will make a PR addressing this.

@AyrA
Copy link

AyrA commented Aug 13, 2015

I just did: #125

This will prevent double escaping of UTF-8. If the server operates in true ascii mode this should not mess up as well, as ascii is only the lower 127 bytes and UTF-8 is identical in this case.

to detect utf-8 I would do something like:

this._utf8=this._feat.indexOf("UTF8")>=0

on line 235 of connection.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants