arib06 opened a new pull request, #3841:
URL: https://github.com/apache/avro/pull/3841

   ## What is the purpose of the change
   
   `JsonParser::decodeString` rejects unpaired low surrogates, but the range 
check uses an exclusive upper bound (`n >= 0xdc00 && n < 0xdfff`), so the last 
low surrogate U+DFFF is not caught. It falls through and is emitted as the 
3-byte sequence `ED BF BF`, which is not valid UTF-8 (it encodes a surrogate 
half). Every other lone low surrogate (U+DC00..U+DFFE) is already rejected. The 
trailing-surrogate check a few lines above already treats U+DFFF as a valid low 
surrogate (`m > 0xdfff`), so the lone-surrogate branch is off by one. This 
makes the bound inclusive so U+DFFF is rejected consistently.
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
   - Added a JSON decoder test asserting that a lone low surrogate, including 
`\udfff`, is rejected. It fails on the current code (U+DFFF is accepted) and 
passes with the fix.
   
   ## Documentation
   
   - Does this pull request introduce a new feature? no
   


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

Reply via email to