Commit f08a8c83 authored by alexpott's avatar alexpott

Issue #2829791 by YesCT: Fix exception message for MachineNameController...

Issue #2829791 by YesCT: Fix exception message for MachineNameController replace_token query parameter
parent f96cbb29
......@@ -6,9 +6,9 @@
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Access\CsrfTokenGenerator;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
......@@ -78,10 +78,10 @@ public function transliterate(Request $request) {
if (isset($replace_pattern) && isset($replace)) {
if (!isset($replace_token)) {
throw new AccessDeniedException("Missing 'replace_token' query parameter.");
throw new AccessDeniedHttpException("Missing 'replace_token' query parameter.");
}
elseif (!$this->tokenGenerator->validate($replace_token, $replace_pattern)) {
throw new AccessDeniedException("Invalid 'replace_token' query parameter.");
throw new AccessDeniedHttpException("Invalid 'replace_token' query parameter.");
}
// Quote the pattern delimiter and remove null characters to avoid the e
......
......@@ -7,8 +7,8 @@
use Drupal\Component\Transliteration\PhpTransliteration;
use Drupal\system\MachineNameController;
use Prophecy\Argument;
use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
/**
* Tests that the machine name controller can transliterate strings as expected.
......@@ -103,7 +103,7 @@ public function testMachineNameController(array $request_params, $expected_conte
public function testMachineNameControllerWithInvalidReplacePattern() {
$request = Request::create('', 'GET', ['text' => 'Bob', 'langcode' => 'en', 'replace' => 'Alice', 'replace_pattern' => 'Bob', 'replace_token' => 'invalid']);
$this->setExpectedException(AccessDeniedException::class, "Invalid 'replace_token' query parameter.");
$this->setExpectedException(AccessDeniedHttpException::class, "Invalid 'replace_token' query parameter.");
$this->machineNameController->transliterate($request);
}
......@@ -113,7 +113,7 @@ public function testMachineNameControllerWithInvalidReplacePattern() {
public function testMachineNameControllerWithMissingToken() {
$request = Request::create('', 'GET', ['text' => 'Bob', 'langcode' => 'en', 'replace' => 'Alice', 'replace_pattern' => 'Bob']);
$this->setExpectedException(AccessDeniedException::class, "Missing 'replace_token' query parameter.");
$this->setExpectedException(AccessDeniedHttpException::class, "Missing 'replace_token' query parameter.");
$this->machineNameController->transliterate($request);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment