Njs: incorrect parsing of UTF-16 escape sequences

Created on 14 Feb 2019  路  5Comments  路  Source: nginx/njs

$ cat u16.js 
var s0 = '褎褘胁邪 asdf 馃憤';
var s1 = '\u0444\u044b\u0432\u0430 asdf \ud83d\udc4d';
var s2 = JSON.parse('"\\u0444\\u044b\\u0432\\u0430 asdf \\ud83d\\udc4d"');
console.log(s0, '|', s1, '|', s2);
$ build/njs u16.js 
'褎褘胁邪 asdf 馃憤' '|' '褎褘胁邪 asdf 锟斤拷锟斤拷锟斤拷' '|' '褎褘胁邪 asdf 馃憤'
bug parser

All 5 comments

@drsm I'm courious how do you find this issue?

@hongzhidao
i've just made a mistake there :) .
then fix it, and hit the bug

@drsm

Please, try this patch to fix the problem.

@lexborisov

Thank you for the patch, works fine for me '\ud83d\udc4d \u{1f44d}'!

deleted

Was this page helpful?
0 / 5 - 0 ratings

Related issues

drsm picture drsm  路  4Comments

rainerhenrichsen picture rainerhenrichsen  路  5Comments

an0ma1ia picture an0ma1ia  路  4Comments

pavelsevcik picture pavelsevcik  路  4Comments

drsm picture drsm  路  3Comments