Perl-Toolchain-Gang / ExtUtils-Manifest

Utilities to write and check a MANIFEST file
https://metacpan.org/release/ExtUtils-Manifest/
Other
4 stars 7 forks source link

#!include directives can create broken MANIFEST.SKIP files if target lacks trailing \n #14

Open kentfredric opened 9 years ago

kentfredric commented 9 years ago

The internal function _include_mskip assumes the included file is \n terminated, and parses it as an array of "\n" terminated values.

It then appends a "#end " line to the array, and then later returns it to be joined with join q[], @list.

However, this means if a file lacking a terminating \n will deliver:

@list = (
   ...
   "second-last-line\n"
   "last-line"
   "#end statement appeneded"
)

Which when joined with q[] gives:

   "second-last-line
    last-line#end statement appended"

Which subsequently parses as

    skipfile: "second-last-line"
    skipfile: "last-line#end" comment:  "statement appended"

Which of course fails to skip the file called "last-line"

Proposed solution exists in https://github.com/kentfredric/ExtUtils-Manifest/commits/fixes

@@ -504,6 +504,9 @@ sub _include_mskip_file {
     push @lines, "\n#!start included $mskip\n";
     push @lines, $_ while <M>;
     close M;
+    # Ensure the last line that came from an included skip file has a trailing \n
+    # or the one after it gets join()'d onto the end of it!
+    $lines[-1] =~ s/\n?$/\n/;
     push @lines, "#!end included $mskip\n\n";
     return @lines;
}