Skip to content

Square brackets in alert messages are not rendered correctly #1104

Open
@henrymercer

Description

@henrymercer

Describe the bug
Square brackets in alert messages [ and ] are rendered as \[ and \] respectively.

Version
CodeQL extension version: 1.5.10
CodeQL CLI version: 2.7.5
Platform: darwin x64

To reproduce
Run the following query on a JavaScript (for instance) project:

/**
 * @kind alert
 */
import javascript
select any(File f), "[] test"

Right click the query in the query history view and select "View Alerts (SARIF)". Observe that the square brackets are correctly escaped as \\[ and \\] per the SARIF spec:

Literal square brackets ("[" and "]") in the link text of a plain text message SHALL be escaped with a backslash (""). Since JSON itself treats the backslash as an escape character, the backslash SHALL be doubled.

Observe that the square brackets are not correctly escaped in the alert message:

image

Expected behavior
The alert message should be "[] test"

Metadata

Metadata

Assignees

No one assigned

    Labels

    VSCodebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions