Closed crasyangel closed 3 years ago
@crasyangel ,
Thanks for the report.
Feel free to test the following patch: https://gist.github.com/xeioex/e62bc5667f10bf4ca27282cb2e94ac50
Please, also note that the problem may occur only with byte strings. We are in the process of deprecating them. Byte strings may contain invalid UTF-8 sequences. And in JS, according the spec, this is invalid string. This is why some methods may fail, because they expect valid UTF-8 sequences.
At this moment (0.7.0) the only way to create them is through njs_vm_value_string_set()
, njs_vm_value_string_alloc()
APIs (this API is used in r.variables
, r.requestText
).
If you need a type for arbitrary byte sequences use Buffer
or Uint8Array
.
There are also Request Buffer properties like r.rawVariables
or r.requestBuffer
.
@crasyangel ,
Thanks for the report.
Feel free to test the following patch: https://gist.github.com/xeioex/e62bc5667f10bf4ca27282cb2e94ac50
Please, also note that the problem may occur only with byte strings. We are in the process of deprecating them. Byte strings may contain invalid UTF-8 sequences. And in JS, according the spec, this is invalid string. This is why some methods may fail, because they expect valid UTF-8 sequences.
At this moment (0.7.0) the only way to create them is through
njs_vm_value_string_set()
,njs_vm_value_string_alloc()
APIs (this API is used inr.variables
,r.requestText
).If you need a type for arbitrary byte sequences use
Buffer
orUint8Array
. There are also Request Buffer properties liker.rawVariables
orr.requestBuffer
.
Good Patch. Problem Solved
njs version: 0.7.0
Should fail when decodeURIComponent with error: "malformed URI", but actually not. njs_string_decode_uri->njs_string_decode_uri_cp(expect_percent is zero)->njs_utf8_decode->NJS_UNICODE_ERROR, not 0xFFFFFFFF, and cannot goto uri_error
In previous versions, njs_utf8_decode2/njs_utf8_decode return 0xFFFFFFFF when error. Why change to NJS_UNICODE_ERROR/0x1FFFFF