Skip Menu |

This queue is for tickets about the YAML-Syck CPAN distribution.

Report information
The Basics
Id: 70933
Status: resolved
Priority: 0/
Queue: YAML-Syck

People
Owner: TODDR [...] cpan.org
Requestors: jsailor [...] jesnetplus.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in:
  • 1.12
  • 1.17
Fixed in: 1.20_01



Subject: LoadFile doesn't work on non-regular-files
lib/YAML/Syck.pm contains the following definition for LoadFile: ### sub LoadFile { my $file = shift; if ( _is_openhandle($file) ) { if( -z $file ) { die("Cannot load an empty file"); }; Load(do { local $/; <$file> }); } else { if(!-e $file || -z $file) { die("'$file' is empty or non-existant"); } open(my $fh, '<', $file) or die "Cannot read from $file: $!"; Load(do { local $/; <$fh> }); } } ### This makes LoadFile refuse to load anything for which -z returns true, which is unfortunate, because -z appears to return true on things like *STDIN (when a TTY or various other things.) Simple test case: $ (echo '---'; echo 'hello: world') | perl -MYAML::Syck -e 'print Dump(LoadFile(\*STDIN))' Perl is the standard package for Debian squeeze Show quoted text
> This is perl, v5.10.1 (*) built for i486-linux-gnu-thread-multi > (with 53 registered patches, see perl -V for more detail)
I agree. I think I was being a little too agressive in my checks when I put it in. The reason I did so was because the error is a little misleading when it fails on an empty file handle: Usage: YAML::Syck::LoadJSON(s) at /Users/todd/YAML-Syck/blib/lib/JSON/Syck.pm line 31. I could slurp the file handle first, but This could take up a significant amount of memory doing so, which is why the code is written this way. Considering the code used to work this way though, I'll be putting it back. https://github.com/toddr/YAML- Syck/commit/b0d67433d53947ac8d8789327914031d0773c7fa