Skip to content

CSP directive names with adjacent hyphens are highlighted #2661

@edukisto

Description

@edukisto

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions