CodeGenieApp / CodeGenieApp/serverless-express
Binary Content Type with Dots or Other Regex
- Vorherrschende Sprache
- JavaScript
- Sterne
- 5.3k
- Forks
- 676
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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).
Beitragsleitfaden
Rechercherichtung
Read src/is-binary.js at line 24 and trace how contentTypes become a matcher. Reproduce the XLSX example, then check the existing tests for binary matching. Done means literal dots no longer broaden matches and wildcard handling follows the project's chosen content-type semantics.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- aws, express, javascript, node.js
- Bereich
- api, backend, cloud
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 38/100