Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binary Content Type with Dots or Other Regex #663

Open
hnryjms opened this issue Nov 26, 2023 · 0 comments
Open

Binary Content Type with Dots or Other Regex #663

hnryjms opened this issue Nov 26, 2023 · 0 comments

Comments

@hnryjms
Copy link

hnryjms commented Nov 26, 2023

The is-binary.js 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 ..*

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant