Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Revision history for Perl extension JavaScript::Minifier::XS.

{{$NEXT}}
- Fixes CVE-2026-56017, which caused Perl to SEGFAULT when calling
minify(). Thanks to CPANSec for raising the issue, and providing a
prototype fix.

0.15 2021-10-15 20:21:23-07:00 America/Vancouver
- GH#8 - preserve newlines when collapsing whitespace; if a block of
Expand Down
7 changes: 4 additions & 3 deletions XS.xs
Original file line number Diff line number Diff line change
Expand Up @@ -446,13 +446,14 @@ Node* JsTokenizeString(JsDoc* doc, const char* string) {
char ch = 0;

/* find last non-whitespace, non-comment node */
while (nodeIsWHITESPACE(last) || nodeIsCOMMENT(last))
while (last && (nodeIsWHITESPACE(last) || nodeIsCOMMENT(last)))
last = last->prev;

ch = last->contents[last->length-1];
if (last && (last->length > 0))
ch = last->contents[last->length-1];

/* see if we're "division" or "regexp" */
if (nodeIsIDENTIFIER(last) && nodeEquals(last, "return")) {
if (last && nodeIsIDENTIFIER(last) && nodeEquals(last, "return")) {
/* returning a regexp from a function */
_JsExtractLiteral(doc, node);
}
Expand Down
14 changes: 14 additions & 0 deletions t/CVE-2026-56017.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/perl

use strict;
use warnings;
use Test::More;
use JavaScript::Minifier::XS qw(minify);

###############################################################################
# CVE-2026-56017
eval { minify('/') };
pass 'minified the JS without SEGFAULTing';

###############################################################################
done_testing();
Loading