Skip to content

Commit

Permalink
Fixed bug #20200 : Invalid JSON produced with specific error messag
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Feb 19, 2014
1 parent 2679192 commit 9da6470
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions CodeSniffer/Reports/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,17 @@ public function generateFileReport(
$showSources=false,
$width=80
) {

$filename = str_replace('"', '\"', $report['filename']);
$filename = str_replace('/', '\/', $report['filename']);
$filename = str_replace('\\', '\\\\', $report['filename']);
$filename = str_replace('"', '\"', $filename);
$filename = str_replace('/', '\/', $filename);
echo "\"$filename\":{";
echo '"errors":'.$report['errors'].',"warnings":'.$report['warnings'].',"messages":[';

$messages = '';
foreach ($report['messages'] as $line => $lineErrors) {
foreach ($lineErrors as $column => $colErrors) {
foreach ($colErrors as $error) {
$error['message'] = str_replace('\\', '\\\\', $error['message']);
$error['message'] = str_replace('"', '\"', $error['message']);
$error['message'] = str_replace('/', '\/', $error['message']);

Expand Down
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
<license uri="https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt">BSD 3-Clause License</license>
<notes>
- Improved detection of nested IF statements that use the alternate IF/ENDIF syntax
- Fixed bug #20200 : Invalid JSON produced with specific error message
</notes>
<contents>
<dir name="/">
Expand Down

0 comments on commit 9da6470

Please sign in to comment.