Skip to content

Commit af43eca

Browse files
committed
Invalid exclude rules inside a ruleset.xml file are now ignored instead of potentially causing out of memory errors
1 parent dddc22e commit af43eca

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

package.xml

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
2929
- The indent property of PEAR.Classes.ClassDeclaration has been removed
3030
-- Instead of calculating the indent of the brace, it just ensures the brace is aligned with the class keyword
3131
-- Other sniffs can be used to ensure the class itself is indented correctly
32+
- Invalid exclude rules inside a ruleset.xml file are now ignored instead of potentially causing out of memory errors
33+
-- Using the -vv command line argument now also shows the invalid exclude rule as XML
3234
- Includes all changes from the 2.8.1 release
3335
- Fixed bug #1333 : The new autoloader breaks some frameworks with custom autoloaders
3436
- Fixed bug #1334 : Undefined offset when explaining standard with custom sniffs

src/Ruleset.php

+10
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,16 @@ public function processRuleset($rulesetPath, $depth=0)
372372

373373
if (isset($rule->exclude) === true) {
374374
foreach ($rule->exclude as $exclude) {
375+
if (isset($exclude['name']) === false) {
376+
if (PHP_CODESNIFFER_VERBOSITY > 1) {
377+
echo str_repeat("\t", $depth);
378+
echo "\t\t* ignoring empty exclude rule *".PHP_EOL;
379+
echo "\t\t\t=> ".$exclude->asXML().PHP_EOL;
380+
}
381+
382+
continue;
383+
}
384+
375385
if ($this->shouldProcessElement($exclude) === false) {
376386
continue;
377387
}

0 commit comments

Comments
 (0)