Skip to content

Commit 1abf34e

Browse files
authored
fix: check for existance of port on host (#545)
1 parent 040871f commit 1abf34e

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

src/http/routes/object/getObject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async function requestHandler(
5454
if (!request.isAuthenticated) {
5555
// The bucket must be public to access its content
5656
if (!bucket?.public) {
57-
throw ERRORS.AccessDenied('Access denied to this bucket')
57+
throw ERRORS.NoSuchBucket(bucketName)
5858
}
5959
}
6060

src/http/routes/object/getObjectInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async function requestHandler(
4646
// Not Authenticated flow
4747
if (!request.isAuthenticated) {
4848
if (!bucket?.public) {
49-
throw ERRORS.AccessDenied('Access denied to this bucket')
49+
throw ERRORS.NoSuchBucket(bucketName)
5050
}
5151
}
5252

src/http/routes/tus/lifecycle.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ export function generateUrl(
9999
const port = req.headers['x-forwarded-port']
100100

101101
if (typeof port === 'string' && port && !['443', '80'].includes(port)) {
102-
host += `:${req.headers['x-forwarded-port']}`
102+
if (!host.includes(':')) {
103+
host += `:${req.headers['x-forwarded-port']}`
104+
} else {
105+
host = host.replace(/:\d+$/, `:${req.headers['x-forwarded-port']}`)
106+
}
103107
}
104108
}
105109

src/storage/protocols/s3/signature-v4.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,11 @@ export class SignatureV4 {
329329
const host = `host:${xForwardedHost.toLowerCase()}`
330330

331331
if (port && !['443', '80'].includes(port)) {
332-
return host + ':' + port
332+
if (!host.includes(':')) {
333+
return host + ':' + port
334+
} else {
335+
return host.replace(/:\d+$/, `:${port}`)
336+
}
333337
}
334338
return host
335339
}

0 commit comments

Comments
 (0)