Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugs: When the path contains the special characters will fail to access the S3 service #2

Open
WenyXu opened this issue Oct 15, 2022 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@WenyXu
Copy link
Collaborator

WenyXu commented Oct 15, 2022

When we try to operate resources where the path contains special characters, it generates an incorrect signature.

There is a example in the /tests/behavior/read_write_test.go#L78

// creates a file with special chars should be success
func testCreateFileWithSpecialChars(t *testing.T, op *yadal.Operator) {
	path := fmt.Sprintf("%s %s", uuid.New().String(), "!@#$%^&*()_+-=;'><,?.txt")

	o := op.Object(path)
	err := o.Create(context.TODO())
	assert.Nilf(t, err, "%s", err)

	meta, err := o.Metadata(context.TODO())
	assert.Nilf(t, err, "%s", err)

	assert.Equal(t, interfaces.FILE, meta.Mode())
	assert.Equal(t, uint64(0), *meta.ContentLength())

	err = o.Delete(context.TODO())
	assert.Nilf(t, err, "%s", err)
}

Then we will receive:

<?xml version="1.0" encoding="UTF-8"?>
<Error>
   <Code>SignatureDoesNotMatch</Code>
   <Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
   <Key>d9a2080a-c33a-4c83-a42b-e0f3255979d5 !@#$%^&amp;*()_+-=;'&gt;&lt;,?.txt</Key>
   <BucketName>test</BucketName>
   <Resource>/test/d9a2080a-c33a-4c83-a42b-e0f3255979d5 !@#$%^&amp;*()_+-=;'&gt;&lt;,?.txt</Resource>
   <Region>us-west-01</Region>
   <RequestId>171E56F294000824</RequestId>
   <HostId>d2593ff9-ea7b-4553-bc29-df692d774e27</HostId>
</Error>
@WenyXu WenyXu added bug Something isn't working good first issue Good for newcomers labels Oct 15, 2022
@Xuanwo
Copy link

Xuanwo commented Nov 11, 2022

case '-', '_', '.', '~', '/', '(', ')', '!', '*', '\'': // §2.3 Unreserved characters (mark)

I'm guessing '(', ')', '!', '*', '\'' also need to be percent encoded.

BTW, this project is awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants