Subject: | Minifying non-javascript text crashes perl |
If you try to minify some text that is not JavaScript, perl crashes.
Attached is a test to show this behavior and attempt to verify the
original text would be returned in such a case.
Subject: | minify_non_javascript.t |
use strict;
use warnings;
use Test::More tests => 1;
use JavaScript::Minifier::XS qw(minify);
use POSIX ();
unless (fork) {
eval {
my $original = 'not javascript';
my $minified = minify($original);
if ($minified eq $original) {
POSIX::_exit(0);
}
else {
diag "wanted '$original', got '$minified'";
POSIX::_exit(1);
}
};
diag "Minifying died";
POSIX::_exit(2);
}
wait;
ok $? == 0, "minifying non-javascript gives original content back and doesn't crash"
or do { $? & 127 and diag "Core dump" };