CodeGenieApp / CodeGenieApp/serverless-express

Binary Content Type with Dots or Other Regex

Ouverte
#663 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
JavaScript
Étoiles
5.3k
Forks
676
Métriques de merge des PR
Aucune PR mergée en 30 j

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).

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
aws, express, javascript, node.js
Domaine
api, backend, cloud
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
38/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.