question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Quotes and other special characters get HTML encoded

See original GitHub issue

Variables with special characters such as single and double quotes get HTML encoded.

For example:

{
    "test1": "Hello ' <> \" characters",
    "test2": "Hello {{replace}}"
}
18n.__('test1');
18n.__('test2', {replace: '<> \' "'});

will result in the following strings

test1 = "Hello ' <> " characters"
test2 = "Hello &lt;&gt; &#39; &quot;"

Is this a bug because I can’t find a configuration to disable HTML encoding

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

24reactions
dominicbartlcommented, May 3, 2018

@mashpie I found those issues as well, though I’m not rendering any HTML, the strings above come straight from i18n. Just found out i18n is using Mustache, so adding 3 brackets {{{ ... }}} fixes the issue.

So the following PR is no longer needed https://github.com/mashpie/i18n-node/pull/366

0reactions
mashpiecommented, Dec 7, 2022

feel free to submit an improving PR.

It should posibly also adress the following:

People using mustache should Know how to use it https://github.com/janl/mustache.js#variables

People wanting to opt-out can do so by i18n.configure({mustacheConfig.disable: true}) as described quite high in https://github.com/mashpie/i18n-node#list-of-all-configuration-options

Read more comments on GitHub >

github_iconTop Results From Across the Web

Common HTML entities used for typography - W3C Wiki
These are the members of the automated “Smart Quotes” set of characters incorporated into most popular word processing platforms. They are often encoded...
Read more >
Special Characters in HTML - DeGraeve.com
Special Characters in HTML ; right double quote, ” ; double low-9 quote, „ ; dagger, † ; double dagger, ‡ ; per...
Read more >
HTML codes and HTML special characters: The complete list
Character Entity name Entity number Hex Code Description A A &#65 &#x41 Capital A a a &#97 &#x61 Lowercase A À &Agrave &#192 &#xC0 Capital A‑grave...
Read more >
Escaping Quotes & other special characters to get HTML ...
I have Excel cells that contain Newlines, Quotes & few more special characters. I wrote a formula in the last column which is...
Read more >
HTML URL Encoding Reference - W3Schools
Character From Windows‑1252 From UTF‑8 space %20 %20 ! %21 %21 " %22 %22
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found