Merge pull request #178 from crazy-max/optional-utf8

Make "OPTS UTF8 ON" optional
This commit is contained in:
Julien Laffaye
2020-07-30 09:57:23 -04:00
committed by GitHub
2 changed files with 22 additions and 3 deletions

12
ftp.go
View File

@@ -53,6 +53,7 @@ type dialOptions struct {
explicitTLS bool
conn net.Conn
disableEPSV bool
disableUTF8 bool
location *time.Location
debugOutput io.Writer
dialFunc func(network, address string) (net.Conn, error)
@@ -176,6 +177,13 @@ func DialWithDisabledEPSV(disabled bool) DialOption {
}}
}
// DialWithDisabledUTF8 returns a DialOption that configures the ServerConn with UTF8 option disabled
func DialWithDisabledUTF8(disabled bool) DialOption {
return DialOption{func(do *dialOptions) {
do.disableUTF8 = disabled
}}
}
// DialWithLocation returns a DialOption that configures the ServerConn with specified time.Location
// The location is used to parse the dates sent by the server which are in server's timezone
func DialWithLocation(location *time.Location) DialOption {
@@ -280,7 +288,9 @@ func (c *ServerConn) Login(user, password string) error {
}
// Switch to UTF-8
err = c.setUTF8()
if !c.options.disableUTF8 {
err = c.setUTF8()
}
// If using implicit TLS, make data connections also use TLS
if c.options.tlsConfig != nil {