Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kentfredric opened this issue Apr 6, 2015 · 0 comments
Labels

Comments

@kentfredric
Copy link

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;
}
kentfredric added a commit to kentfredric/ExtUtils-Manifest that referenced this issue Apr 6, 2015
kentfredric added a commit to kentfredric/ExtUtils-Manifest that referenced this issue Apr 6, 2015
kentfredric added a commit to kentfredric/ExtUtils-Manifest that referenced this issue Apr 6, 2015
…files

Internally, all lines are in an array, with each entry \n terminated.

However, this leads to a problem when the last line in in an included
file lacks a \n, as this gets stored as:

  [ "secondlastline\n", "lastline", "#!end included" ]

Which stringifies as:

  secondlastline
  lastline#!end included

And that lastline doesn't match the files its supposed to.

Closes GH Perl-Toolchain-Gang#14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants