-
-
Notifications
You must be signed in to change notification settings - Fork 14
Closed
Description
Describe the bug
string
s in the output of highlight
function with html: true
maybe malformed when the sql query contains special characters in hardcoded string
It seems that the special characters should be escaped in the output
To Reproduce
Steps to reproduce the behavior:
- Use code below
const { highlight } = require('sql-highlight')
let sqlString = "select * from a where b = 'array<map<string,string>>';"
let highlighted = highlight(sqlString, { html: true })
console.log(highlighted)
- And execute it with nodejs
Actual behavior
- It prints
<span class="sql-hl-keyword">select</span> <span class="sql-hl-special">*</span> <span class="sql-hl-keyword">from</span> a <span class="sql-hl-keyword">where</span> b <span class="sql-hl-special">=</span> <span class="sql-hl-string">'array<map<string,string>>'</span><span class="sql-hl-special">;</span>
- And if I try to put the 'array<map<string,string>>' into html
The browser will treat it as
And user will see
Expected behavior
- It prints
<span class="sql-hl-keyword">select</span> <span class="sql-hl-special">*</span> <span class="sql-hl-keyword">from</span> a <span class="sql-hl-keyword">where</span> b <span class="sql-hl-special">=</span> <span class="sql-hl-string">'array<map<string,string>>'</span><span class="sql-hl-special">;</span>
- And if I put the 'array<map<string,string>>' into html
The browser will treat it as
And user will see
Node.js (please complete the following information):
- Version v16.17.1
Browser (please complete the following information):
- OS: MacOS
- Browser Chrome
- Version 108.0.5359.124
Metadata
Metadata
Assignees
Labels
No labels