jhthorsen/json-validator

Given a valid JSON string that ends in a newline, the schema() method emits a warning

davidcantrell-bb opened this issue · 3 comments

  • JSON::Validator version: 4.10
  • Perl version: 5.30.1
  • Operating system: Mac OS Catalina

Steps to reproduce the behavior

JSON::Validator->new()->schema(q!{ "type": "object" }
!)

note the newline before the closing quote.

Expected behavior

There should be no warning

Actual behavior

A warning is emitted: Unsuccessful stat on filename containing newline at /blahblah/JSON/Validator.pm line 317.

Suggested fix

Tightly scoped no warnings 'newline';, something like ...

my $loadable = do {
  no warnings 'newline';
  (blessed $source && ($source->can('scheme') || $source->isa('Mojo::File')))
  || -f $source
  || (!ref $source && $source =~ /^\w/);
};

I just chased this error message for hours until I looked for open issues, thanks!

There, have a trivial fix :-)

This is now fixed in #233.