Skip to content

Commit

Permalink
disallow reserved characters
Browse files Browse the repository at this point in the history
  • Loading branch information
aaperis committed Jul 30, 2024
1 parent b9acf34 commit c7134e0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion sda/cmd/s3inbox/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ func formatUploadFilePath(filePath string) (string, error) {
outPath := strings.ReplaceAll(filePath, "\\", "/")

// [\x00-\x1F\x7F] is the control character set
re := regexp.MustCompile(`[\\:\*\?"<>\|\x00-\x1F\x7F]`)
re := regexp.MustCompile(`[\\<>"\|\x00-\x1F\x7F\!\*\'\(\)\;\:\@\&\=\+\$\,\?\%\#\[\]]`)

dissallowedChars := re.FindAllString(outPath, -1)
if dissallowedChars != nil {
Expand Down
4 changes: 2 additions & 2 deletions sda/cmd/s3inbox/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ func (suite *ProxyTests) TestFormatUploadFilePath() {
assert.EqualError(suite.T(), err, "filepath contains mixed '\\' and '/' characters")

// no mixed "\" and "/" but not allowed
weirdPath = `dq\sw:*?"<>|\t\sdf.c4gh`
weirdPath = `dq\sw:*?"<>|\t\sdf!s'(a);w@4&f=+e$,g#[]d%.c4gh`
_, err = formatUploadFilePath(weirdPath)
assert.EqualError(suite.T(), err, "filepath contains disallowed characters: :, *, ?, \", <, >, |")
assert.EqualError(suite.T(), err, "filepath contains disallowed characters: :, *, ?, \", <, >, |, !, ', (, ), ;, @, &, =, +, $, ,, #, [, ], %")
}

0 comments on commit c7134e0

Please sign in to comment.