@@ -16,8 +16,8 @@ use pest::Parser;
1616#[ derive( Parser ) ]
1717#[ grammar = "parser/grammar/json_path_9535.pest" ]
1818pub ( super ) struct JSPathParser ;
19- const MAX_VAL : i64 = 9007199254740991 ; // Maximum safe integer value in JavaScript
20- const MIN_VAL : i64 = -9007199254740991 ; // Minimum safe integer value in JavaScript
19+ // const MAX_VAL: i64 = 9007199254740991; // Maximum safe integer value in JavaScript
20+ // const MIN_VAL: i64 = -9007199254740991; // Minimum safe integer value in JavaScript
2121
2222pub type Parsed < T > = Result < T , JsonPathError > ;
2323
@@ -122,13 +122,13 @@ pub fn selector(rule: Pair<Rule>) -> Parsed<Selector> {
122122 validate_js_str ( child. as_str ( ) . trim ( ) ) ?. to_string ( ) ,
123123 ) ) ,
124124 Rule :: wildcard_selector => Ok ( Selector :: Wildcard ) ,
125- Rule :: index_selector => Ok ( Selector :: Index ( validate_range (
125+ Rule :: index_selector => Ok ( Selector :: Index (
126126 child
127127 . as_str ( )
128128 . trim ( )
129129 . parse :: < i64 > ( )
130130 . map_err ( |e| ( e, "wrong integer" ) ) ?,
131- ) ? ) ) ,
131+ ) ) ,
132132 Rule :: slice_selector => {
133133 let ( start, end, step) = slice_selector ( child) ?;
134134 Ok ( Selector :: Slice ( start, end, step) )
@@ -237,16 +237,7 @@ pub fn singular_query_segments(rule: Pair<Rule>) -> Parsed<Vec<SingularQuerySegm
237237 }
238238 Ok ( segments)
239239}
240- fn validate_range ( val : i64 ) -> Result < i64 , JsonPathError > {
241- if val > MAX_VAL || val < MIN_VAL {
242- Err ( JsonPathError :: InvalidJsonPath ( format ! (
243- "Value {} is out of range" ,
244- val
245- ) ) )
246- } else {
247- Ok ( val)
248- }
249- }
240+
250241pub fn slice_selector ( rule : Pair < Rule > ) -> Parsed < ( Option < i64 > , Option < i64 > , Option < i64 > ) > {
251242 let mut start = None ;
252243 let mut end = None ;
@@ -255,12 +246,12 @@ pub fn slice_selector(rule: Pair<Rule>) -> Parsed<(Option<i64>, Option<i64>, Opt
255246
256247 for r in rule. into_inner ( ) {
257248 match r. as_rule ( ) {
258- Rule :: start => start = Some ( validate_range ( get_int ( r) ? ) ?) ,
259- Rule :: end => end = Some ( validate_range ( get_int ( r) ? ) ?) ,
249+ Rule :: start => start = Some ( get_int ( r) ?) ,
250+ Rule :: end => end = Some ( get_int ( r) ?) ,
260251 Rule :: step => {
261252 step = {
262253 if let Some ( int) = r. into_inner ( ) . next ( ) {
263- Some ( validate_range ( get_int ( int) ? ) ?)
254+ Some ( get_int ( int) ?)
264255 } else {
265256 None
266257 }
@@ -319,15 +310,7 @@ pub fn literal(rule: Pair<Rule>) -> Parsed<Literal> {
319310 if num. contains ( '.' ) || num. contains ( 'e' ) || num. contains ( 'E' ) {
320311 Ok ( Literal :: Float ( num. parse :: < f64 > ( ) . map_err ( |e| ( e, num) ) ?) )
321312 } else {
322- let num = num. trim ( ) . parse :: < i64 > ( ) . map_err ( |e| ( e, num) ) ?;
323- if num > MAX_VAL || num < MIN_VAL {
324- Err ( JsonPathError :: InvalidNumber ( format ! (
325- "number out of bounds: {}" ,
326- num
327- ) ) )
328- } else {
329- Ok ( Literal :: Int ( num) )
330- }
313+ Ok ( Literal :: Int ( num. trim ( ) . parse :: < i64 > ( ) . map_err ( |e| ( e, num) ) ?) )
331314 }
332315 }
333316
0 commit comments