CodeGenieApp / CodeGenieApp/serverless-express
Binary Content Type with Dots or Other Regex
- Lenguaje dominante
- JavaScript
- Estrellas
- 5.3k
- Forks
- 676
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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).
Guía de contribución
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- aws, express, javascript, node.js
- Área
- api, backend, cloud
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 38/100