Skip to content

Commit ebd42d4

Browse files
johan13Johan Levin
and
Johan Levin
authored
fix: unescape plus in ALB query string (#660)
Co-authored-by: Johan Levin <[email protected]>
1 parent 75e9de3 commit ebd42d4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/event-sources/aws/alb.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ function getPathWithQueryStringUseUnescapeParams ({
1313
// decode everything back into utf-8 text.
1414
if (event.multiValueQueryStringParameters) {
1515
for (const key in event.multiValueQueryStringParameters) {
16-
const formattedKey = decodeURIComponent(key)
17-
query[formattedKey] = event.multiValueQueryStringParameters[key].map(value => decodeURIComponent(value))
16+
const formattedKey = decodeUrlencoded(key)
17+
query[formattedKey] = event.multiValueQueryStringParameters[key].map(value => decodeUrlencoded(value))
1818
}
1919
} else {
2020
for (const key in event.queryStringParameters) {
21-
const formattedKey = decodeURIComponent(key)
22-
query[formattedKey] = decodeURIComponent(event.queryStringParameters[key])
21+
const formattedKey = decodeUrlencoded(key)
22+
query[formattedKey] = decodeUrlencoded(event.queryStringParameters[key])
2323
}
2424
}
2525

@@ -29,6 +29,11 @@ function getPathWithQueryStringUseUnescapeParams ({
2929
})
3030
}
3131

32+
// Decode an "application/x-www-form-urlencoded" encoded string.
33+
function decodeUrlencoded (val) {
34+
return decodeURIComponent(val.replace(/\+/g, '%20'))
35+
}
36+
3237
const getRequestValuesFromAlbEvent = ({ event }) => {
3338
const values = getRequestValuesFromEvent({
3439
event,

0 commit comments

Comments
 (0)