Title: `string`s in the output of `highlight` function with `html: true` maybe malformed · Issue #90 · scriptcoded/sql-highlight · GitHub
Open Graph Title: `string`s in the output of `highlight` function with `html: true` maybe malformed · Issue #90 · scriptcoded/sql-highlight
X Title: `string`s in the output of `highlight` function with `html: true` maybe malformed · Issue #90 · scriptcoded/sql-highlight
Description: Describe the bug strings 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 Repro...
Open Graph Description: Describe the bug strings 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 ...
X Description: Describe the bug strings 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 ...
Opengraph URL: https://github.com/scriptcoded/sql-highlight/issues/90
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`string`s in the output of `highlight` function with `html: true` maybe malformed","articleBody":"**Describe the bug**\r\n`string`s in the output of `highlight` function with `html: true` maybe malformed when the sql query contains special characters in hardcoded string\r\nIt seems that the special characters should be escaped in the output\r\n\r\n**To Reproduce**\r\nSteps to reproduce the behavior:\r\n- Use code below\r\n```\r\nconst { highlight } = require('sql-highlight')\r\nlet sqlString = \"select * from a where b = 'array\u003cmap\u003cstring,string\u003e\u003e';\"\r\nlet highlighted = highlight(sqlString, { html: true })\r\nconsole.log(highlighted)\r\n```\r\n- And execute it with nodejs\r\n\r\n**Actual behavior**\r\n- It prints\r\n`\u003cspan class=\"sql-hl-keyword\"\u003eselect\u003c/span\u003e \u003cspan class=\"sql-hl-special\"\u003e*\u003c/span\u003e \u003cspan class=\"sql-hl-keyword\"\u003efrom\u003c/span\u003e a \u003cspan class=\"sql-hl-keyword\"\u003ewhere\u003c/span\u003e b \u003cspan class=\"sql-hl-special\"\u003e=\u003c/span\u003e \u003cspan class=\"sql-hl-string\"\u003e'array\u003cmap\u003cstring,string\u003e\u003e'\u003c/span\u003e\u003cspan class=\"sql-hl-special\"\u003e;\u003c/span\u003e`\r\n- And if I try to put the **\u003cspan class=\"sql-hl-string\"\u003e'array\u003cmap\u003cstring,string\u003e\u003e'\u003c/span\u003e** into html\r\nThe browser will treat it as\r\n\r\nAnd user will see\r\n\r\n\r\n**Expected behavior**\r\n- It prints\r\n`\u003cspan class=\"sql-hl-keyword\"\u003eselect\u003c/span\u003e \u003cspan class=\"sql-hl-special\"\u003e*\u003c/span\u003e \u003cspan class=\"sql-hl-keyword\"\u003efrom\u003c/span\u003e a \u003cspan class=\"sql-hl-keyword\"\u003ewhere\u003c/span\u003e b \u003cspan class=\"sql-hl-special\"\u003e=\u003c/span\u003e \u003cspan class=\"sql-hl-string\"\u003e'array\u0026ltmap\u0026ltstring,string\u0026gt\u0026gt'\u003c/span\u003e\u003cspan class=\"sql-hl-special\"\u003e;\u003c/span\u003e`\r\n- And if I put the **\u003cspan class=\"sql-hl-string\"\u003e'array\u0026ltmap\u0026ltstring,string\u0026gt\u0026gt'\u003c/span\u003e** into html\r\nThe browser will treat it as\r\n\r\nAnd user will see\r\n\r\n\r\n**Node.js (please complete the following information):**\r\n - Version v16.17.1\r\n\r\n**Browser (please complete the following information):**\r\n - OS: MacOS\r\n - Browser Chrome\r\n - Version 108.0.5359.124\r\n","author":{"url":"https://github.com/SidneyTTW","@type":"Person","name":"SidneyTTW"},"datePublished":"2023-01-13T08:45:30.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/90/sql-highlight/issues/90"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:77652672-e42a-516e-10d5-811dc6448f8f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DB18:307977:239F75F:2EBD9BF:698196C7 |
| html-safe-nonce | 2320c08920078470f1f3b3d6515743515c2030bfdcdc2f1f953408abc02cf4e4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQjE4OjMwNzk3NzoyMzlGNzVGOjJFQkQ5QkY6Njk4MTk2QzciLCJ2aXNpdG9yX2lkIjoiNDgwODU0MDQ2NDYxNTYyNjQzOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 274cfe0d2990fe688490429dbcf04cefea1b556055e26184d9127215a83b6da3 |
| hovercard-subject-tag | issue:1531924649 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/scriptcoded/sql-highlight/90/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9250cd4207e1b2d42e3884c6528e33c3c542fbe22620f3fb69503c36f3463912/scriptcoded/sql-highlight/issues/90 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9250cd4207e1b2d42e3884c6528e33c3c542fbe22620f3fb69503c36f3463912/scriptcoded/sql-highlight/issues/90 |
| og:image:alt | Describe the bug strings 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 ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | SidneyTTW |
| hostname | github.com |
| expected-hostname | github.com |
| None | e137814e266030874fd2c86863529d0622b13889eeda04148c57654b6ea84ad6 |
| turbo-cache-control | no-preview |
| go-import | github.com/scriptcoded/sql-highlight git https://github.com/scriptcoded/sql-highlight.git |
| octolytics-dimension-user_id | 6452991 |
| octolytics-dimension-user_login | scriptcoded |
| octolytics-dimension-repository_id | 147309066 |
| octolytics-dimension-repository_nwo | scriptcoded/sql-highlight |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 147309066 |
| octolytics-dimension-repository_network_root_nwo | scriptcoded/sql-highlight |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | dd58d68a7813bbec9c91422c8c35f4af33832d70 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width