diff --git a/src/Output.php b/src/Output.php index 974dde80..b542a98b 100644 --- a/src/Output.php +++ b/src/Output.php @@ -441,7 +441,7 @@ public function writeResult(Result $result, ErrorFormatter $errorFormatter, $ign sprintf( ' ', $fileError['line'], - $fileError['message'], + htmlspecialchars($fileError['message'], ENT_COMPAT, 'UTF-8'), $fileError['source'] ) . PHP_EOL diff --git a/tests/Output.phpt b/tests/Output.phpt index 95814a57..c0b04a6e 100644 --- a/tests/Output.phpt +++ b/tests/Output.phpt @@ -8,6 +8,7 @@ require __DIR__ . '/../vendor/autoload.php'; use JakubOnderka\PhpParallelLint\ErrorFormatter; use JakubOnderka\PhpParallelLint\GitLabOutput; +use JakubOnderka\PhpParallelLint\CheckstyleOutput; use JakubOnderka\PhpParallelLint\IWriter; use JakubOnderka\PhpParallelLint\Result; use JakubOnderka\PhpParallelLint\SyntaxError; @@ -46,6 +47,27 @@ class OutputTest extends Tester\TestCase } } + public function testCheckstyleOutput() + { + $errors = array( + new JakubOnderka\PhpParallelLint\SyntaxError( + 'sample.php', + 'Parse error: syntax error, unexpected \'"\' in ./sample.php on line 3' + ), + ); + + $result = new Result($errors, array(), array(), 0); + $writer = new TestWriter(); + $output = new CheckstyleOutput($writer); + + $output->writeResult($result, new ErrorFormatter(), true); + $xml = $writer->getLogs(); + $parsed = @simplexml_load_string($xml); + + Assert::contains("unexpected '"'", $xml); + Assert::type('SimpleXMLElement', $parsed); + } + public function getGitLabOutputData() { return array(