JSON-Viewer icon indicating copy to clipboard operation
JSON-Viewer copied to clipboard

Format JSON replaces unicode characters code with the actual unicode character

Open git-hub-user opened this issue 5 years ago • 2 comments

When I have

{"FreeTextInput":"\u003Cscript\u003Ealert(\u0022links\u0022);\u003C/script\u003E"}

in a Notepad++ editor tab, select the text and apply menu Plugins - JSON Viewer - format JSON, the result is:

{
	"FreeTextInput": "<script>alert(\"links\");</script>"
}

I am not sure if this is by design, but I surely surprised me.

If doesn't matter if the Encoding is set to ANSI or to UTF-8.

git-hub-user avatar Jun 15 '20 15:06 git-hub-user

The bug is that "Format Json" is unescaping the escaped characters / and u**** in strings, instead of leaving them in the original escaped form. The escaped characters \ plus ", , b, f, n, r, or t don't change. Maybe it is related to the fact that those characters need to be escaped too in c++, while / doesn't?

user21760 avatar Nov 10 '21 18:11 user21760

现在的文件都是默认的utf-8 ,打开后中文乱码显示为ansi

junfoon avatar Oct 19 '22 02:10 junfoon