-
-
Notifications
You must be signed in to change notification settings - Fork 13
string
s in the output of highlight
function with html: true
maybe malformed
#90
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
Comments
Escape HTML entities within generated HTML tags. Add option to allow user to provide custom escaper. Could be used to disable escaping completely. While this is considered a bug the solution requires a feature implementation to integrate nicely, hence the feat and not fix label. Refs: #90
Thank you for reporting this! I agree that escaping should be considered expected behavior. I've added basic HTML entity escaping in v4.3.0 which is now live on NPM. It uses a basic escaper based on escape-html. This can be configured using options. I opted to escape quotes on top of brackets and ampersands as you suggested in your issue. Please verify that this fix resolves your issue. Have a nice weekend! |
Looks great. Thanks for the quick response! |
P.S. to anyone interested, explanation for why this is a minor release and not a patch can be found in 672fc9c |
Describe the bug
string
s in the output ofhighlight
function withhtml: true
maybe malformed when the sql query contains special characters in hardcoded stringIt seems that the special characters should be escaped in the output
To Reproduce
Steps to reproduce the behavior:
Actual behavior
<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>
The browser will treat it as
And user will see
Expected behavior
<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>
The browser will treat it as
And user will see
Node.js (please complete the following information):
Browser (please complete the following information):
The text was updated successfully, but these errors were encountered: