Merge pull request #93 from trlim/master

Fix wrong handling of unicode escape code
This commit is contained in:
Alex Crichton 2016-04-12 23:05:40 -07:00
commit ef60313a5d
3 changed files with 5 additions and 6 deletions

View file

@ -1,4 +1,3 @@
use std::ascii::AsciiExt;
use std::char; use std::char;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::error::Error; use std::error::Error;
@ -490,7 +489,7 @@ impl<'a> Parser<'a> {
Some((pos, c @ 'U')) => { Some((pos, c @ 'U')) => {
let len = if c == 'u' {4} else {8}; let len = if c == 'u' {4} else {8};
let num = &me.input[pos+1..]; let num = &me.input[pos+1..];
let num = if num.len() >= len && num.is_ascii() { let num = if num.char_indices().nth(len).map(|(i, _)| i).unwrap_or(0) == len {
&num[..len] &num[..len]
} else { } else {
"invalid" "invalid"

View file

@ -1,4 +1,4 @@
{ {
"answer4": {"type": "string", "value": "\u03B4"}, "answer4": {"type": "string", "value": "\u03B4α"},
"answer8": {"type": "string", "value": "\u03B4"} "answer8": {"type": "string", "value": "\u03B4β"}
} }

View file

@ -1,2 +1,2 @@
answer4 = "\u03B4" answer4 = "\u03B4α"
answer8 = "\U000003B4" answer8 = "\U000003B4β"