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

CSP directive names with adjacent hyphens are highlighted #2661

Closed
edukisto opened this issue Nov 30, 2020 · 0 comments · Fixed by #2662
Closed

CSP directive names with adjacent hyphens are highlighted #2661

edukisto opened this issue Nov 30, 2020 · 0 comments · Fixed by #2662

Comments

@edukisto
Copy link
Contributor

Information

  • Language: CSP
  • Plugins: none

Does the problem still occur in the latest version of Prism?

Yes.

Description

Directive names with adjacent hyphens are highlighted. For example, Prism highlights default-src inside the following sequences:

fake-default-src 'none'
default-src-is-a-fake 'none'

The error is caused by \b. The first \b has been there from the beginning. Then I added the last \b. Both of them are erroneous, because \b uses [0-9A-Z_a-z] (see ECMA-262, sections 21.2.1, 21.2.2.12, 21.2.2.6.1), whereas directive names consist of [-0-9A-Za-z] (see CSP 1.0, CSP 1.1, CSP2, and CSP3).

Code snippet

The code being highlighted incorrectly.
fake-default-src 'none'
default-src-is-a-fake 'none'

The default-src part should not be highlighted.

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

Successfully merging a pull request may close this issue.

1 participant