diff -ruN File-Slurp-9999.12-orig/lib/File/Slurp.pm File-Slurp-9999.12/lib/File/Slurp.pm
--- File-Slurp-9999.12-orig/lib/File/Slurp.pm 2006-02-17 07:13:51.000000000 +0100
+++ File-Slurp-9999.12/lib/File/Slurp.pm 2007-06-08 16:21:06.858317759 +0200
@@ -6,6 +6,7 @@
use POSIX qw( :fcntl_h ) ;
use Fcntl qw( :DEFAULT ) ;
use Symbol ;
+BEGIN { eval 'use UNIVERSAL::isa' }
my $is_win32 = $^O =~ /win32/i ;
@@ -85,7 +86,7 @@
# check if we are reading from a handle (glob ref or IO:: object)
- if ( ref $file_name ) {
+ if ( ref $file_name && (UNIVERSAL::isa($file_name, 'GLOB') || UNIVERSAL::isa($file_name, 'IO')) ) {
# slurping a handle so use it and don't open anything.
# set the block size so we know it is a handle and read that amount
diff -ruN File-Slurp-9999.12-orig/t/file_object.t File-Slurp-9999.12/t/file_object.t
--- File-Slurp-9999.12-orig/t/file_object.t 1970-01-01 01:00:00.000000000 +0100
+++ File-Slurp-9999.12/t/file_object.t 2007-06-08 16:16:43.644607504 +0200
@@ -0,0 +1,45 @@
+#!perl -T
+use strict;
+use Test::More;
+use File::Slurp;
+use Scalar::Util qw(tainted);
+
+plan tests => 4;
+
+my $path = "data.txt";
+my $data = "random junk\n";
+
+# create an object
+my $obj = FileObject->new($path);
+isa_ok( $obj, 'FileObject' );
+is( "$obj", $path, "check that the object correctly stringifies" );
+
+SKIP: {
+ # write something to that file
+ open(FILE, ">$path") or skip 4, "can't write to '$path': $!";
+ print FILE $data;
+ close(FILE);
+
+ # pass it to read_file()
+ my $content = eval { read_file($obj) };
+ is( $@, '', "passing an object to read_file()" );
+ is( $content, $data, "checking that the content matches the data" );
+}
+
+unlink $path;
+
+
+# the following mimics the parts from Path::Class causing
+# problems with File::Slurp
+package FileObject;
+use overload
+ q[""] => \&stringify, fallback => 1;
+
+sub new {
+ return bless { path => $_[1] }, $_[0]
+}
+
+sub stringify {
+ return $_[0]->{path}
+}
+
diff -ruN File-Slurp-9999.12-orig/t/taint.t File-Slurp-9999.12/t/taint.t
--- File-Slurp-9999.12-orig/t/taint.t 1970-01-01 01:00:00.000000000 +0100
+++ File-Slurp-9999.12/t/taint.t 2007-06-08 16:15:42.852350224 +0200
@@ -0,0 +1,30 @@
+#!perl -T
+use strict;
+use Test::More;
+use File::Slurp;
+use Scalar::Util qw(tainted);
+
+plan tests => 4;
+
+my $path = "data.txt";
+my $data = "random junk\n";
+
+SKIP: {
+ # write something to that file
+ open(FILE, ">$path") or skip 4, "can't write to '$path': $!";
+ print FILE $data;
+ close(FILE);
+
+ # read the file using File::Slurp in scalar context
+ my $content = eval { read_file($path) };
+ is( $@, '', "read_file() in scalar context" );
+ ok( tainted($content), " => returned content should be tainted" );
+
+ # read the file using File::Slurp in list context
+ my @content = eval { read_file($path) };
+ is( $@, '', "read_file() in list context" );
+ ok( tainted($content[0]), " => returned content should be tainted" );
+}
+
+unlink $path;
+