xingcici opened a new pull request, #393:
URL: https://github.com/apache/dubbo-go-hessian2/pull/393

   ## 问题
   
   当 Java 客户端发送含孤立高代理项(lone high surrogate,如 `\ud83d`)的字符串时,`decode2utf8` 
会无条件将其后的 3 个字节当作低代理项合并成一个码点,即便这 3 个字节编码的值不在低代理项范围 `[0xDC00, 0xDFFF]` 
内,导致后续字符被损坏。
   
   **复现字符串**:`"test_go_hessian2\ud83d..."` —— `\ud83d` 是孤立高代理项,后跟 `...`(`0x2E 
0x2E 0x2E`,c2 = 0x002E),不在低代理项范围内。
   
   ## 修复
   
   在 `decode2utf8` 中,读取潜在低代理项后增加校验 `if c2 >= 0xDC00 && c2 <= 
0xDFFF`,仅在确认为合法代理对时才合并;否则将高代理项作为独立的 3 字节序列处理,继续解码后续字符。
   
   ## 测试
   
   新增 `TestDecodeStringLoneHighSurrogateRealWorld`,使用从 Java hessian2 
实际抓取的字节流进行验证。
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to