Skip to content

Commit

Permalink
Don't blindly convert line endings
Browse files Browse the repository at this point in the history
Beause it could be reading binary files! Instead just convert the line
endings in the tests.
  • Loading branch information
theory committed Feb 17, 2024
1 parent 4b1bd15 commit 3546d28
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Revision history for Perl extension WWW-PGXN.

0.13.0 2024-02-17T19:54:17Z
- Added CI tests for Perls 5.10 - 5.38 on Linux, macOS, and Windows.
- Fixed issues that caused test failures on Windows.
- Fixed failures caused by line endings on Windows.
- Updated relevant URLs from http to https.

0.12.4 2013-11-06T05:56:15Z
Expand Down
2 changes: 1 addition & 1 deletion lib/WWW/PGXN.pm
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ sub get {
headers => {},
} unless -e $file;

open my $fh, '<:raw:crlf', $file or return {
open my $fh, '<:raw', $file or return {
success => 0,
status => 500,
reason => $!,
Expand Down
4 changes: 4 additions & 0 deletions t/base.t
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,16 @@ is $pgxn->html_doc_path_for('pair', '0.1.2', 'doc/foo'),

##############################################################################
# Test spec fetching.
my $windows = $^O =~ /^Win/;
ok my $spec = $pgxn->spec, 'Get spec';
$spec =~ s/\r\n/\n/g if $windows;
like $spec, qr{PGXN Meta Spec - The PGXN distribution metadatå specification$}m,
'It should look like the text file';
ok $spec = $pgxn->spec('txt'), 'Get text spec';
$spec =~ s/\r\n/\n/g if $windows;
like $spec, qr{PGXN Meta Spec - The PGXN distribution metadatå specification$}m,
'It should look like the text file';
ok $spec = $pgxn->spec('html'), 'Get HTML spec';
$spec =~ s/\r\n/\n/g if $windows;
like $spec, qr{<p>PGXN Meta Spec - The PGXN distribution metadatå specification</p>$}m,
'It should look like the HTML file';
3 changes: 3 additions & 0 deletions t/dist.t
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ is_deeply $dist->docs, {

ok my $doc = $dist->body_for_html_doc('README'),
'Fetch the README body';
my $windows = $^O =~ /^Win/;
$doc =~ s/\r\n/\n/g if $windows;

# Contents should be the decoded HTML.
is $doc, do {
Expand All @@ -149,6 +151,7 @@ is $doc, do {
# Do the same for the doc.
ok $doc = $dist->body_for_html_doc('doc/pair'),
'Fetch the doc/pair body';
$doc =~ s/\r\n/\n/g if $windows;
is $doc, do {
my $fn = catfile qw(t mirror dist pair 0.1.1 doc pair.html);
open my $fh, '<:encoding(utf-8)', $fn or die "Cannot open $fn: $!\n";
Expand Down

0 comments on commit 3546d28

Please sign in to comment.