File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -476,7 +476,7 @@ static const bool whitespace[256] = {
476476 ['/' ] = 1 ,
477477};
478478
479- static void
479+ static bool
480480json_eat_comments (JSON_ParserState * state )
481481{
482482 if (state -> cursor + 1 < state -> end ) {
@@ -508,9 +508,10 @@ json_eat_comments(JSON_ParserState *state)
508508 break ;
509509 }
510510 default :
511- return ;
511+ return false ;
512512 }
513513 }
514+ return true;
514515}
515516
516517static inline void
@@ -520,7 +521,9 @@ json_eat_whitespace(JSON_ParserState *state)
520521 if (RB_LIKELY (* state -> cursor != '/' )) {
521522 state -> cursor ++ ;
522523 } else {
523- json_eat_comments (state );
524+ if (!json_eat_comments (state )) {
525+ return ;
526+ }
524527 }
525528 }
526529}
Original file line number Diff line number Diff line change @@ -629,6 +629,13 @@ def test_parse_error_incomplete_hash
629629 end
630630 end
631631
632+ def test_parse_leading_slash
633+ # ref: https://github.com/ruby/ruby/pull/12598
634+ assert_raise ( JSON ::ParserError ) do
635+ JSON . parse ( "/foo/bar" )
636+ end
637+ end
638+
632639 private
633640
634641 def string_deduplication_available?
You can’t perform that action at this time.
0 commit comments