Skip to content

Commit

Permalink
Merge pull request #30 from LulububuApps/bugfix/invalid-config-catch
Browse files Browse the repository at this point in the history
Avoid crashes on invalid configurations
  • Loading branch information
blaues0cke authored Oct 31, 2019
2 parents 3151b78 + 8bf7ad3 commit cc4e1ea
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
config.yml
composer.lock
vendor/
Expand Down
6 changes: 5 additions & 1 deletion src/Config/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ public function prepare()
*/
public function match($path)
{
return preg_match("~^" . $this->computedWildcards . "$~i", $path);
try {
return preg_match("~^" . $this->computedWildcards . "$~i", $path);
} catch (\Exception $exception) {
return false;
}
}

/**
Expand Down
7 changes: 6 additions & 1 deletion src/Redirector/Redirector.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ public function handle(Request $request, Application $app)
foreach ($this->config->getRedirects() as $redirect) {

$redirect->prepare();
$match = $redirect->match($path);

if ($redirect->match($path)) {
if ($match === false) {
$app['logger.flash']->error('Error while parsing the boltredirector <a href="/bolt/file/edit/extensions_config/boltredirector.sahassar.yml">configuration</a>.');
}

if ($match) {
$result = $redirect->getResult($path);
$status = $redirect->getStatusCode();

Expand Down

0 comments on commit cc4e1ea

Please sign in to comment.