Skip Menu |

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

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

People
Owner: TODDR [...] cpan.org
Requestors: dmuey [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: 1.10_01



Subject: use 3 arg form of open() instead of the 2 argument form
Hello, First off, thanks for your hard work on YAML::Syck! Is there a specific reason it uses 2 arg open()s? If not it'd probably be best to change it to do 3 arg open()s. Using 3 argument open() will properly [open|automatically handle] a file name with arbitrary weird characters in it. It is also a little safer regarding "file names" someone passes in an attempt to try to do bad things like a pipe of some sort. (yes it is the caller's responsibility to sanitize data but it's still a good idea no?) Thanks! -- DMuey
On Thu Jul 30 11:35:38 2009, DMUEY wrote: Show quoted text
> Hello, > > First off, thanks for your hard work on YAML::Syck! > > Is there a specific reason it uses 2 arg open()s?
Not anymore. YAML::Syck used to be trying to be perl 5.3 compatible, it's now 5.6 compatible. and 5.6 had the better 3 arg open(). I'd be happy to apply a patch for this, see the boring form letter below: (This is a form-reply that isn't specific to your particular report) YAML::Syck has just acquired one new maintainer (me), it still doesn't have anyone that *cares* about it. But I'm willing to help solve your report & release a new version with the fix if it's easy for me. It now has a Git repository at: http://github.com/avar/YAML-Syck If your report is a patch that fixes a problem, great. Please remake the patch against Git by forking that repo and sending me a pull request on GitHub (or an update to this bug if you prefer git-format-patch(1) or some other repo provider..). Make sure to include a test for what you fixed. If your report is some code that fails (and you have a testcase for it) a patch against the test suite to demonstrate that failure would be very useful. It's OK if the test crashes and burns, see Test::More's docs for how to make TODO tests that fail now, but shouldn't. Even if it segfaults perl C<system $^X => qw/ -Mblib -MYAML::Syck .../> or something like that and checking the return value will do.
Show quoted text
> Not anymore. YAML::Syck used to be trying to be perl 5.3 compatible, > it's now 5.6 compatible. and 5.6 had the better 3 arg open(). > > I'd be happy to apply a patch for this, see the boring form letter > below:
The patch to lib is in gihub and attached. As I'm UTF8 ignorant, I can't provide a test to prove this works as expected, but I see no reason considering the scope of the patch.
Subject: patch.txt
commit 7721be078c8d5df9dc480b1d9dc928b9cb635acc Author: Todd Rinaldo <toddr@cpan.org> Date: Thu Jul 15 14:34:09 2010 -0500 RT 48327 - use 3 arg form of open() instead of the 2 argument form diff --git a/lib/JSON/Syck.pm b/lib/JSON/Syck.pm index 8aa196e..f0af51e 100644 --- a/lib/JSON/Syck.pm +++ b/lib/JSON/Syck.pm @@ -19,7 +19,7 @@ sub DumpFile { } else { local *FH; - open FH, "> $file" or die "Cannot write to $file: $!"; + open(FH, '>', $file) or die "Cannot write to $file: $!"; print FH YAML::Syck::DumpJSON($_[0]); close FH; } @@ -33,7 +33,7 @@ sub LoadFile { } else { local *FH; - open FH, "< $file" or die "Cannot read from $file: $!"; + open(FH, '<', $file) or die "Cannot read from $file: $!"; YAML::Syck::LoadJSON(do { local $/; <FH> }); } } diff --git a/lib/YAML/Syck.pm b/lib/YAML/Syck.pm index 449d5da..f934388 100644 --- a/lib/YAML/Syck.pm +++ b/lib/YAML/Syck.pm @@ -105,7 +105,7 @@ sub DumpFile { } else { local *FH; - open FH, "> $file" or die "Cannot write to $file: $!"; + open(FH, '>', $file) or die "Cannot write to $file: $!"; if ($#_) { print FH YAML::Syck::DumpYAML($_) for @_; } @@ -124,7 +124,7 @@ sub LoadFile { } else { local *FH; - open FH, "< $file" or die "Cannot read from $file: $!"; + open(FH, '<', $file) or die "Cannot read from $file: $!"; Load(do { local $/; <FH> }); } }