Skip to content

Commit

Permalink
Fix early UTF-8 setting
Browse files Browse the repository at this point in the history
Depending on server, this might not work before login.
  • Loading branch information
patrickjuchli committed May 5, 2023
1 parent 97c98f8 commit 02e3d47
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion test/connectivitySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
])
})
});
Expand Down

0 comments on commit 02e3d47

Please sign in to comment.