Skip to content

Commit

Permalink
Only apply YAML preprocessing if the initial parse attempt fails
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeTowers committed Mar 28, 2022
1 parent 2ca5797 commit 9256b87
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Parse/Yaml.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@ public function parse($contents)
{
$yaml = new Parser;

if (!is_null($this->processor)) {
// Only run the preprocessor if parsing fails
try {
$parsed = $yaml->parse($contents);
} catch (\Throwable $throwable) {
if (!$this->processor) {
throw $throwable;
}
$contents = $this->processor->preprocess($contents);
$parsed = $yaml->parse($contents);
}

$parsed = $yaml->parse($contents);

if (!is_null($this->processor)) {
$parsed = $this->processor->process($parsed);
}
Expand Down

0 comments on commit 9256b87

Please sign in to comment.