You've already forked json-iterator
							
							
				mirror of
				https://github.com/json-iterator/go.git
				synced 2025-10-31 00:07:40 +02:00 
			
		
		
		
	control character in string is invalid
This commit is contained in:
		| @@ -2,6 +2,7 @@ package jsoniter | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"unicode/utf16" | 	"unicode/utf16" | ||||||
|  | 	"fmt" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| // ReadString read string from iterator | // ReadString read string from iterator | ||||||
| @@ -16,6 +17,10 @@ func (iter *Iterator) ReadString() (ret string) { | |||||||
| 				return ret | 				return ret | ||||||
| 			} else if c == '\\' { | 			} else if c == '\\' { | ||||||
| 				break | 				break | ||||||
|  | 			} else if c < ' ' { | ||||||
|  | 				iter.ReportError("ReadString", | ||||||
|  | 					fmt.Sprintf(`invalid control character found: %d`, c)) | ||||||
|  | 				return | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		return iter.readStringSlowPath() | 		return iter.readStringSlowPath() | ||||||
|   | |||||||
| @@ -19,7 +19,10 @@ func Test_read_string(t *testing.T) { | |||||||
| 		`"\"`, | 		`"\"`, | ||||||
| 		`"\\\"`, | 		`"\\\"`, | ||||||
| 		"\"\n\"", | 		"\"\n\"", | ||||||
| 		`navy`, | 	} | ||||||
|  | 	for i :=0; i < 32; i++ { | ||||||
|  | 		// control characters are invalid | ||||||
|  | 		badInputs = append(badInputs, string([]byte{'"', byte(i), '"'})) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	for _, input := range badInputs { | 	for _, input := range badInputs { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user