Handle #{ in Engine::parse_json, restrict to object hashes only.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#![cfg(not(feature = "no_object"))]
|
||||
|
||||
use rhai::{Engine, EvalAltResult, Map, Scope, INT};
|
||||
use rhai::{Engine, EvalAltResult, Map, ParseErrorType, Scope, INT};
|
||||
|
||||
#[test]
|
||||
fn test_map_indexing() -> Result<(), Box<EvalAltResult>> {
|
||||
@@ -182,6 +182,14 @@ fn test_map_json() -> Result<(), Box<EvalAltResult>> {
|
||||
);
|
||||
}
|
||||
|
||||
engine.parse_json(&format!("#{}", json), true)?;
|
||||
|
||||
assert!(matches!(
|
||||
*engine.parse_json(" 123", true).expect_err("should error"),
|
||||
EvalAltResult::ErrorParsing(ParseErrorType::MissingToken(token, _), pos)
|
||||
if token == "{" && pos.position() == Some(4)
|
||||
));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user