He-Pin opened a new issue, #3224:
URL: https://github.com/apache/pekko/issues/3224

   ### Motivation
   
   `JsonObjectParser` 使用 256-byte 查表验证 JSON 字符,可能拒绝包含 BOM(Byte Order Mark)或特殊 
Unicode 字符的合法 JSON 输入。
   
   ### 当前代码行为
   
   `JsonObjectParser.scala` 中:
   
   ```scala
   // JsonObjectParser.scala:116-180
   private val outerChars: Array[Byte] = new Array[Byte](256)
   ```
   
   使用 256-byte 查表验证 JSON 顶层字符。任何不在 `[`, `]`, `{`, `,` 或 whitespace 
范围内的字节都会触发错误(通过 `1 / outer` 在 142 行,catch ArithmeticException 后抛出 
FramingException)。
   
   某些合法 JSON 可能包含:
   - UTF-8 BOM(`EF BB BF`)
   - 顶层数组/对象外的特殊字符
   
   ### 预期行为
   
   应正确处理 BOM 前缀,并对非 ASCII 字符更宽容(JSON 规范允许 Unicode 字符)。
   
   ### 代码证据
   
   - 
`stream/src/main/scala/org/apache/pekko/stream/impl/JsonObjectParser.scala:116-180`
 — 查表逻辑和错误处理
   
   ### 复现方式
   
   ```scala
   // 带 BOM 的 JSON 流
   val jsonWithBom = ByteString(Array(0xEF.toByte, 0xBB.toByte, 0xBF.toByte)) 
++ ByteString("""[{"key":"value"}]""")
   Source.single(jsonWithBom)
     .via(JsonFraming.detector)
     .runWith(Sink.head)
   // 可能抛出 FramingException
   ```
   
   ### 影响范围
   
   - 模块:`pekko-stream`
   - 影响从文件/网络读取 JSON 流的用户
   - BOM 前缀是某些系统(如 Windows)的常见输出格式


-- 
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