s3: fix encoding for control characters - Fixes #3345
This commit is contained in:
parent
6ae7bd7914
commit
a8adce9c59
1 changed files with 17 additions and 5 deletions
|
@ -20,6 +20,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -1221,11 +1222,12 @@ func (f *Fs) list(ctx context.Context, bucket, directory, prefix string, addBuck
|
||||||
for {
|
for {
|
||||||
// FIXME need to implement ALL loop
|
// FIXME need to implement ALL loop
|
||||||
req := s3.ListObjectsInput{
|
req := s3.ListObjectsInput{
|
||||||
Bucket: &bucket,
|
Bucket: &bucket,
|
||||||
Delimiter: &delimiter,
|
Delimiter: &delimiter,
|
||||||
Prefix: &directory,
|
Prefix: &directory,
|
||||||
MaxKeys: &maxKeys,
|
MaxKeys: &maxKeys,
|
||||||
Marker: marker,
|
Marker: marker,
|
||||||
|
EncodingType: aws.String(s3.EncodingTypeUrl),
|
||||||
}
|
}
|
||||||
var resp *s3.ListObjectsOutput
|
var resp *s3.ListObjectsOutput
|
||||||
var err error
|
var err error
|
||||||
|
@ -1259,6 +1261,11 @@ func (f *Fs) list(ctx context.Context, bucket, directory, prefix string, addBuck
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
remote := *commonPrefix.Prefix
|
remote := *commonPrefix.Prefix
|
||||||
|
remote, err = url.QueryUnescape(remote)
|
||||||
|
if err != nil {
|
||||||
|
fs.Logf(f, "failed to URL decode %q in listing common prefix: %v", *commonPrefix.Prefix, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
if !strings.HasPrefix(remote, prefix) {
|
if !strings.HasPrefix(remote, prefix) {
|
||||||
fs.Logf(f, "Odd name received %q", remote)
|
fs.Logf(f, "Odd name received %q", remote)
|
||||||
continue
|
continue
|
||||||
|
@ -1278,6 +1285,11 @@ func (f *Fs) list(ctx context.Context, bucket, directory, prefix string, addBuck
|
||||||
}
|
}
|
||||||
for _, object := range resp.Contents {
|
for _, object := range resp.Contents {
|
||||||
remote := aws.StringValue(object.Key)
|
remote := aws.StringValue(object.Key)
|
||||||
|
remote, err = url.QueryUnescape(remote)
|
||||||
|
if err != nil {
|
||||||
|
fs.Logf(f, "failed to URL decode %q in listing: %v", aws.StringValue(object.Key), err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
if !strings.HasPrefix(remote, prefix) {
|
if !strings.HasPrefix(remote, prefix) {
|
||||||
fs.Logf(f, "Odd name received %q", remote)
|
fs.Logf(f, "Odd name received %q", remote)
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in a new issue