s3store: Filter newlines out of metadata
This commit is contained in:
parent
30811b6579
commit
85a26150a3
|
@ -90,7 +90,9 @@ import (
|
||||||
|
|
||||||
// This regular expression matches every character which is not defined in the
|
// This regular expression matches every character which is not defined in the
|
||||||
// ASCII tables which range from 00 to 7F, inclusive.
|
// ASCII tables which range from 00 to 7F, inclusive.
|
||||||
var nonASCIIRegexp = regexp.MustCompile(`([^\x00-\x7F])`)
|
// It also matches the \r and \n characters which are not allowed in values
|
||||||
|
// for HTTP headers.
|
||||||
|
var nonASCIIRegexp = regexp.MustCompile(`([^\x00-\x7F]|[\r\n])`)
|
||||||
|
|
||||||
// See the tusd.DataStore interface for documentation about the different
|
// See the tusd.DataStore interface for documentation about the different
|
||||||
// methods.
|
// methods.
|
||||||
|
|
|
@ -37,7 +37,7 @@ func TestNewUpload(t *testing.T) {
|
||||||
assert.Equal(s3obj, store.Service)
|
assert.Equal(s3obj, store.Service)
|
||||||
|
|
||||||
s1 := "hello"
|
s1 := "hello"
|
||||||
s2 := "men?"
|
s2 := "men???hi"
|
||||||
|
|
||||||
gomock.InOrder(
|
gomock.InOrder(
|
||||||
s3obj.EXPECT().CreateMultipartUpload(&s3.CreateMultipartUploadInput{
|
s3obj.EXPECT().CreateMultipartUpload(&s3.CreateMultipartUploadInput{
|
||||||
|
@ -53,8 +53,8 @@ func TestNewUpload(t *testing.T) {
|
||||||
s3obj.EXPECT().PutObject(&s3.PutObjectInput{
|
s3obj.EXPECT().PutObject(&s3.PutObjectInput{
|
||||||
Bucket: aws.String("bucket"),
|
Bucket: aws.String("bucket"),
|
||||||
Key: aws.String("uploadId.info"),
|
Key: aws.String("uploadId.info"),
|
||||||
Body: bytes.NewReader([]byte(`{"ID":"uploadId+multipartId","Size":500,"SizeIsDeferred":false,"Offset":0,"MetaData":{"bar":"menü","foo":"hello"},"IsPartial":false,"IsFinal":false,"PartialUploads":null}`)),
|
Body: bytes.NewReader([]byte(`{"ID":"uploadId+multipartId","Size":500,"SizeIsDeferred":false,"Offset":0,"MetaData":{"bar":"menü\r\nhi","foo":"hello"},"IsPartial":false,"IsFinal":false,"PartialUploads":null}`)),
|
||||||
ContentLength: aws.Int64(int64(171)),
|
ContentLength: aws.Int64(int64(177)),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ func TestNewUpload(t *testing.T) {
|
||||||
Size: 500,
|
Size: 500,
|
||||||
MetaData: map[string]string{
|
MetaData: map[string]string{
|
||||||
"foo": "hello",
|
"foo": "hello",
|
||||||
"bar": "menü",
|
"bar": "menü\r\nhi",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue