CodeGenieApp / CodeGenieApp/serverless-express

Binary Content Type with Dots or Other Regex

Open
#663 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
5.3k
Forks
676
PR merge metrics
No merged PRs in 30d

Description

The [`is-binary.js`](https://github.com/brettstack/serverless-express/blob/mainline/src/is-binary.js#L24) checker converts the developer-specified content types to Regex without escaping them, which is can cause overly broad selection or other issues during the Regex match.

For example, the following binary selector for an XLSX document (`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet `) will match any character at the `.` of this content type, and also leads the tailing asterisk to become `..*`

```js
export const handler = serverlessExpress({
app,
binarySettings: {
contentTypes: [
'application/pdf',
'application/vnd.openxmlformats-officedocument.*'
]
}
});
```

I think developers would generally expect to either pass their own Regex, or for the `*` character to be the only recognized character (and possibly other glob patterns, but not all of Regex).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.