From c159655015f447753c56b6df62656becc0563dd8 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Sun, 20 Sep 2015 18:50:16 +0100 Subject: [PATCH] Issue #2568775 by dawehner, lauriii, alexpott, joelpittet, xjm: Replace remaining !placeholder for Non-URL HTML outputs only for $e->getMessage() --- core/lib/Drupal/Core/Config/ConfigImporter.php | 2 +- .../Core/FileTransfer/Form/FileTransferAuthorizeForm.php | 4 ++-- core/lib/Drupal/Core/Updater/Updater.php | 4 ++-- core/modules/config/src/Tests/ConfigImporterTest.php | 3 ++- core/modules/migrate/src/MigrateExecutable.php | 6 +++--- .../migrate/tests/src/Unit/MigrateExecutableTest.php | 3 ++- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/core/lib/Drupal/Core/Config/ConfigImporter.php b/core/lib/Drupal/Core/Config/ConfigImporter.php index c02d4fe886f..13b87954c7d 100644 --- a/core/lib/Drupal/Core/Config/ConfigImporter.php +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php @@ -762,7 +762,7 @@ class ConfigImporter { } } catch (\Exception $e) { - $this->logError($this->t('Unexpected error during import with operation @op for @name: !message', array('@op' => $op, '@name' => $name, '!message' => $e->getMessage()))); + $this->logError($this->t('Unexpected error during import with operation @op for @name: @message', array('@op' => $op, '@name' => $name, '@message' => $e->getMessage()))); // Error for that operation was logged, mark it as processed so that // the import can continue. $this->setProcessedConfiguration($collection, $op, $name); diff --git a/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php b/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php index 7bc0f1cc518..1273943446b 100644 --- a/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php +++ b/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php @@ -179,8 +179,8 @@ class FileTransferAuthorizeForm extends FormBase { catch (\Exception $e) { // The format of this error message is similar to that used on the // database connection form in the installer. - $form_state->setErrorByName('connection_settings', $this->t('Failed to connect to the server. The server reports the following message: !message For more help installing or updating code on your server, see the handbook.', array( - '!message' => '

' . $e->getMessage() . '

', + $form_state->setErrorByName('connection_settings', $this->t('Failed to connect to the server. The server reports the following message:

@message

For more help installing or updating code on your server, see the handbook.', array( + '@message' => $e->getMessage(), '@handbook_url' => 'https://www.drupal.org/documentation/install/modules-themes', ))); } diff --git a/core/lib/Drupal/Core/Updater/Updater.php b/core/lib/Drupal/Core/Updater/Updater.php index 4869b1cfec1..c23c996791f 100644 --- a/core/lib/Drupal/Core/Updater/Updater.php +++ b/core/lib/Drupal/Core/Updater/Updater.php @@ -257,7 +257,7 @@ class Updater { return $this->postUpdateTasks(); } catch (FileTransferException $e) { - throw new UpdaterFileTransferException(t('File Transfer failed, reason: !reason', array('!reason' => strtr($e->getMessage(), $e->arguments)))); + throw new UpdaterFileTransferException(t('File Transfer failed, reason: @reason', array('@reason' => strtr($e->getMessage(), $e->arguments)))); } } @@ -295,7 +295,7 @@ class Updater { return $this->postInstallTasks(); } catch (FileTransferException $e) { - throw new UpdaterFileTransferException(t('File Transfer failed, reason: !reason', array('!reason' => strtr($e->getMessage(), $e->arguments)))); + throw new UpdaterFileTransferException(t('File Transfer failed, reason: @reason', array('@reason' => strtr($e->getMessage(), $e->arguments)))); } } diff --git a/core/modules/config/src/Tests/ConfigImporterTest.php b/core/modules/config/src/Tests/ConfigImporterTest.php index 0e695bf3a5a..51fabae2c74 100644 --- a/core/modules/config/src/Tests/ConfigImporterTest.php +++ b/core/modules/config/src/Tests/ConfigImporterTest.php @@ -7,6 +7,7 @@ namespace Drupal\config\Tests; +use Drupal\Component\Utility\Html; use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Config\ConfigImporter; use Drupal\Core\Config\ConfigImporterException; @@ -295,7 +296,7 @@ class ConfigImporterTest extends KernelTestBase { $logs = $this->configImporter->getErrors(); $this->assertEqual(count($logs), 1); - $this->assertEqual($logs[0], SafeMarkup::format("Unexpected error during import with operation @op for @name: 'config_test' entity with ID '@name_secondary' already exists.", array('@op' => 'create', '@name' => $name_primary, '@name_secondary' => 'secondary'))); + $this->assertEqual($logs[0], Html::escape("Unexpected error during import with operation create for $name_primary: 'config_test' entity with ID 'secondary' already exists.")); } /** diff --git a/core/modules/migrate/src/MigrateExecutable.php b/core/modules/migrate/src/MigrateExecutable.php index bc86158e538..d2762ade293 100644 --- a/core/modules/migrate/src/MigrateExecutable.php +++ b/core/modules/migrate/src/MigrateExecutable.php @@ -222,7 +222,7 @@ class MigrateExecutable implements MigrateExecutableInterface { } catch (\Exception $e) { $this->message->display( - $this->t('Migration failed with source plugin exception: !e', array('!e' => $e->getMessage())), 'error'); + $this->t('Migration failed with source plugin exception: @e', array('@e' => $e->getMessage())), 'error'); $this->migration->setStatus(MigrationInterface::STATUS_IDLE); return MigrationInterface::RESULT_FAILED; } @@ -299,8 +299,8 @@ class MigrateExecutable implements MigrateExecutableInterface { } catch (\Exception $e) { $this->message->display( - $this->t('Migration failed with source plugin exception: !e', - array('!e' => $e->getMessage())), 'error'); + $this->t('Migration failed with source plugin exception: @e', + array('@e' => $e->getMessage())), 'error'); $this->migration->setStatus(MigrationInterface::STATUS_IDLE); return MigrationInterface::RESULT_FAILED; } diff --git a/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php index 63d509955c6..ed237aaecf1 100644 --- a/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php +++ b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php @@ -7,6 +7,7 @@ namespace Drupal\Tests\migrate\Unit; +use Drupal\Component\Utility\Html; use Drupal\migrate\Entity\MigrationInterface; use Drupal\migrate\Plugin\MigrateIdMapInterface; use Drupal\migrate\MigrateException; @@ -72,7 +73,7 @@ class MigrateExecutableTest extends MigrateTestCase { // Ensure that a message with the proper message was added. $this->message->expects($this->once()) ->method('display') - ->with("Migration failed with source plugin exception: $exception_message"); + ->with("Migration failed with source plugin exception: " . Html::escape($exception_message)); $result = $this->executable->import(); $this->assertEquals(MigrationInterface::RESULT_FAILED, $result);