diff --git a/CHANGELOG.md b/CHANGELOG.md index 55a8a95..b7b6ecf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Fixed: Improve closing sequence for control socket. (#224, #228) - Fixed: Avoid deprecation error. (#221) +- Fixed: Set default settings before login in case there are non-ascii characters in user or password. (#229, @lgpseu) ## 5.0.2 diff --git a/src/Client.ts b/src/Client.ts index 25cafe2..270cb41 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -237,7 +237,7 @@ export class Client { this.availableListCommands = supportsMLSD ? LIST_COMMANDS_MLSD : LIST_COMMANDS_DEFAULT await this.send("TYPE I") // Binary mode await this.sendIgnoringError("STRU F") // Use file structure - await this.sendIgnoringError("OPTS UTF8 ON") // Some servers expect UTF-8 to be enabled explicitly + await this.sendIgnoringError("OPTS UTF8 ON") // Some servers expect UTF-8 to be enabled explicitly and setting before login might not have worked. if (supportsMLSD) { await this.sendIgnoringError("OPTS MLST type;size;modify;unique;unix.mode;unix.owner;unix.group;unix.ownername;unix.groupname;") // Make sure MLSD listings include all we can parse } @@ -272,7 +272,8 @@ export class Client { secureOptions.host = secureOptions.host ?? options.host await this.useTLS(secureOptions) } - // Set utf8 on before login in case there are non-ascii characters in user or password + // Set UTF-8 on before login in case there are non-ascii characters in user or password. + // Note that this might not work before login depending on server. await this.sendIgnoringError("OPTS UTF8 ON") await this.login(options.user, options.password) await this.useDefaultSettings() diff --git a/test/connectivitySpec.js b/test/connectivitySpec.js index d225cc0..1122de4 100644 --- a/test/connectivitySpec.js +++ b/test/connectivitySpec.js @@ -85,11 +85,12 @@ describe("Connectivity", function() { password: "test" }).then(() => { assert.deepEqual(this.server.receivedCommands, [ + "OPTS UTF8 ON", "USER test", "FEAT", "TYPE I", "STRU F", - "OPTS UTF8 ON" + "OPTS UTF8 ON", ]) }) });