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

Structured header parameter parser is too loose #454

Open
gibson042 opened this issue Jun 6, 2022 · 1 comment
Open

Structured header parameter parser is too loose #454

gibson042 opened this issue Jun 6, 2022 · 1 comment

Comments

@gibson042
Copy link
Contributor

A parameter name missing leading and/or trailing _ is accepted, probably erroneously. For example, _modifiers: a Modifiers, (as currently in proposal-regexp-modifiers spec) renders like "_modifiers (a Modifiers)" with the literal _ visible and "modifiers" not wrapped in a <var> element (as currently in proposal-regexp-modifiers HTML).

The responsible code appears to be at

({ match, text } = eat(text, /^[A-Za-z0-9_] */i));

/^[A-Za-z0-9_] */i should probably be replaced with /^_[A-Za-z0-9] _ */i, or maybe /^(?:_[A-Za-z0-9] _|[A-Za-z0-9] ) */i if we want to support parameter names not wrapped in _ (which I'd personally be against). And incidentally, I also note that the i flag is redundant with A-Za-z.

@bakkot
Copy link
Contributor

bakkot commented Jun 6, 2022

Yeah, there should be a lint rule for this. (I prefer a lint rule to outright rejecting these inputs because it's nicer to get some output while iterating.)

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

2 participants