Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 318308

Summary: creates invalid JSON for strings with null characters
Product: [RT] Jetty Reporter: Marcus Better <marcus>
Component: serverAssignee: Greg Wilkins <gregw>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: jetty-inbox
Version: 8.0.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
test case none

Description Marcus Better CLA 2010-06-29 08:59:24 EDT
org.eclipse.jetty.util.ajax.JSON produces invalid JSON for strings containing the null characeter U+0000. It puts a byte with numeric value 0 in the string, but this is not allowed in JSON according to RFC 4627. The resulting JSON is not compatible with other parsers, for example WebKit's JSON.parse() will barf on it.
Comment 1 Marcus Better CLA 2010-06-29 09:01:44 EDT
Created attachment 172995 [details]
test case

This Groovy script demonstrates the bug and compares with the Jackson generator which quotes the null byte correctly.
Comment 2 Greg Wilkins CLA 2010-06-29 10:13:51 EDT
fixed in r2057.  will be in 7.1.5.

thanks for the report.
Comment 3 Greg Wilkins CLA 2010-06-29 10:14:40 EDT
the fix will propagate to 8 soon after the 7.1.5 release