diff --git a/core/lib/Drupal/Core/Logger/LoggerBase.php b/core/lib/Drupal/Core/Logger/LoggerBase.php index 6bcef8c..2a81271 100644 --- a/core/lib/Drupal/Core/Logger/LoggerBase.php +++ b/core/lib/Drupal/Core/Logger/LoggerBase.php @@ -37,7 +37,7 @@ protected function parseMessagePlaceholders(&$message, array &$context) { if (($start = strpos($message, '{')) !== FALSE && strpos($message, '}') > $start) { $has_ps3 = TRUE; // Replace PS3 messages containing placeholders. - $message = preg_replace('/\{(.*)\}/', '@$1', $message); + $message = preg_replace('/\{(.*)\}/U', '@$1', $message); } foreach ($context as $key => $variable) { // PSR3 style placeholders. @@ -49,7 +49,7 @@ protected function parseMessagePlaceholders(&$message, array &$context) { $key = '@' . $key; } } - if (strpos($key, '@') === 0 || strpos($key, '%') === 0 || strpos($key, '!') === 0) { + if (!empty($key) && ($key[0] === '@' || $key[0] === '%' || $key[0] === '!')) { // The key is now in \Drupal\Component\Utility\String::format() style. $variables[$key] = $variable; } diff --git a/core/tests/Drupal/Tests/Core/Logger/LoggerBaseTest.php b/core/tests/Drupal/Tests/Core/Logger/LoggerBaseTest.php index 54cd479..5a2b79e 100644 --- a/core/tests/Drupal/Tests/Core/Logger/LoggerBaseTest.php +++ b/core/tests/Drupal/Tests/Core/Logger/LoggerBaseTest.php @@ -80,6 +80,11 @@ public function providerTestParseMessagePlaceholders() { array('message' => 'User W-\\};~{&! created @', 'context' => array('' => '')), array('message' => 'User W-\\};~{&! created @', 'context' => array()), ), + // Messsage with double PSR3 style messages. + array( + array('message' => 'Test {with} two {encapsuled} strings', 'context' => array('with' => 'together', 'encapsuled' => 'awesome')), + array('message' => 'Test @with two @encapsuled strings', 'context' => array('@with' => 'together', '@encapsuled' => 'awesome')), + ), ); }