Use different method to ensure unicode escape code is ASCII of expected length
This commit is contained in:
parent
8dbc107441
commit
6426b02d3d
|
@ -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"
|
||||||
|
|
Loading…
Reference in a new issue