Skip to content

Commit 946b96b

Browse files
committed
bug #19922 [Yaml][TwigBridge] Use JSON_UNESCAPED_SLASHES for lint commands output (chalasr)
This PR was merged into the 2.7 branch. Discussion ---------- [Yaml][TwigBridge] Use JSON_UNESCAPED_SLASHES for lint commands output | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Slashes are escaped when sing the `lint:twig` and `lint:yaml` commands with the `format` option set to `json`, giving such results: ```json [ { "file": "yaml\/wrong\/1.yml", "valid": false, "message": "Unable to parse at line 1 (near \";:cc`\")." } ] ``` That's not convenient as file paths may be reused (e.g. copy-pasted). Results stay fine as error messages are already escaped: ```json [ { "file": "yaml/wrong/1.yml", "valid": false, "message": "Unable to parse at line 1 (near \";:cc`\")." } ] ``` Commits ------- 0427594 Use JSON_UNESCAPED_SLASHES for lint commands output
2 parents f321989 + 0427594 commit 946b96b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Symfony/Bridge/Twig/Command/LintCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ private function displayJson(OutputInterface $output, $filesInfo)
202202
}
203203
});
204204

205-
$output->writeln(json_encode($filesInfo, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0));
205+
$output->writeln(json_encode($filesInfo, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT JSON_UNESCAPED_SLASHES : 0));
206206

207207
return min($errors, 1);
208208
}

src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ private function displayJson(OutputInterface $output, $filesInfo)
156156
}
157157
});
158158

159-
$output->writeln(json_encode($filesInfo, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0));
159+
$output->writeln(json_encode($filesInfo, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES : 0));
160160

161161
return min($errors, 1);
162162
}

0 commit comments

Comments
 (0)