Commit 0f6f909f authored by alexpott's avatar alexpott

Issue #2568781 by dawehner, lauriii, stefan.r: Replace remaining !placeholder...

Issue #2568781 by dawehner, lauriii, stefan.r: Replace remaining !placeholder for Non-URL HTML outputs only for $entity->label()
parent 2ee4a7fb
......@@ -388,7 +388,7 @@ function hook_contextual_links_alter(array &$links, $group, array $route_paramet
// Dynamically use the menu name for the title of the menu_edit contextual
// link.
$menu = \Drupal::entityManager()->getStorage('menu')->load($route_parameters['menu']);
$links['menu_edit']['title'] = t('Edit menu: !label', array('!label' => $menu->label()));
$links['menu_edit']['title'] = t('Edit menu: @label', array('@label' => $menu->label()));
}
}
......
......@@ -114,7 +114,7 @@ public function buildComponents(array &$build, array $entities, array $displays,
$build[$id]['feed_icon'] = array(
'#theme' => 'feed_icon',
'#url' => $entity->getUrl(),
'#title' => t('!title feed', array('!title' => $entity->label())),
'#title' => t('@title feed', array('@title' => $entity->label())),
);
}
......
......@@ -6,6 +6,7 @@
*/
namespace Drupal\aggregator\Tests;
use Drupal\Component\Utility\Html;
/**
* Add feed test.
......@@ -44,6 +45,23 @@ public function testAddFeed() {
$this->deleteFeed($feed);
}
/**
* Ensures that the feed label is escaping when rendering the feed icon.
*/
public function testFeedLabelEscaping() {
$feed = $this->createFeed(NULL, ['title[0][value]' => 'Test feed title <script>alert(123);</script>']);
$this->checkForMetaRefresh();
$this->drupalGet('aggregator/sources/' . $feed->id());
$this->assertResponse(200);
$result = $this->xpath('//h1');
$this->assertEqual((string) $result[0], 'Test feed title alert(123);');
// Ensure the feed icon title is escaped.
$this->assertTrue(strpos(str_replace(["\n", "\r"], '', $this->getRawContent()), 'class="feed-icon"> Subscribe to Test feed title &lt;script&gt;alert(123);&lt;/script&gt; feed</a>') !== FALSE);
}
/**
* Tests feeds with very long URLs.
*/
......
......@@ -115,7 +115,6 @@ function config_translation_config_translation_info(&$info) {
$info[$entity_type_id . '_fields'] = array(
'base_route_name' => "entity.field_config.{$entity_type_id}_field_edit_form",
'entity_type' => 'field_config',
'title' => '!label field',
'class' => '\Drupal\config_translation\ConfigFieldMapper',
'base_entity_type' => $entity_type_id,
'weight' => 10,
......@@ -144,7 +143,7 @@ function config_translation_config_translation_info(&$info) {
$info[$entity_type_id] = array(
'class' => '\Drupal\config_translation\ConfigEntityMapper',
'base_route_name' => $base_route_name,
'title' => '!label !entity_type',
'title' => $entity_type->getLowercaseLabel(),
'names' => array(),
'entity_type' => $entity_type_id,
'weight' => 10,
......
......@@ -154,11 +154,7 @@ public function setEntity(ConfigEntityInterface $entity) {
* {@inheritdoc}
*/
public function getTitle() {
// Title based on the entity label. Should be translated for display in the
// current page language. The title placeholder is later escaped for
// display.
$entity_type_info = $this->entityManager->getDefinition($this->entityType);
return $this->t($this->pluginDefinition['title'], array('!label' => $this->entity->label(), '!entity_type' => $entity_type_info->getLowercaseLabel()));
return $this->entity->label() . ' ' . $this->pluginDefinition['title'];
}
/**
......
......@@ -100,8 +100,8 @@ protected function getSourceElement(LanguageInterface $source_language, $source_
return array(
'#type' => 'item',
'#title' => $this->t('!label <span class="visually-hidden">(!source_language)</span>', array(
'!label' => $this->t($this->definition->getLabel()),
'#title' => $this->t('@label <span class="visually-hidden">(!source_language)</span>', array(
'@label' => $this->definition->getLabel(),
'!source_language' => $source_language->getName(),
)),
'#markup' => $value,
......@@ -162,8 +162,8 @@ protected function getSourceElement(LanguageInterface $source_language, $source_
protected function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config) {
// Add basic properties that apply to all form elements.
return array(
'#title' => $this->t('!label <span class="visually-hidden">(!source_language)</span>', array(
'!label' => $this->t($this->definition['label']),
'#title' => $this->t('@label <span class="visually-hidden">(!source_language)</span>', array(
'@label' => $this->definition['label'],
'!source_language' => $translation_language->getName(),
)),
'#default_value' => $translation_config,
......
......@@ -7,6 +7,7 @@
namespace Drupal\config_translation\Tests;
use Drupal\Component\Utility\Html;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\simpletest\WebTestBase;
......@@ -116,8 +117,8 @@ public function testMapperListPage() {
$entity_type = \Drupal::entityManager()->getDefinition($test_entity->getEntityTypeId());
$this->drupalGet($base_url . '/translate');
$title = t('@label @entity_type', array('@label' => $test_entity->label(), '@entity_type' => $entity_type->getLowercaseLabel()));
$title = t('Translations for %label', array('%label' => $title));
$title = $test_entity->label() . ' ' . $entity_type->getLowercaseLabel();
$title = 'Translations for <em class="placeholder">' . Html::escape($title) . '</em>';
$this->assertRaw($title);
$this->assertRaw('<th>' . t('Language') . '</th>');
......
......@@ -70,7 +70,7 @@ protected function setUp() {
$definition = array(
'class' => '\Drupal\config_translation\ConfigEntityMapper',
'base_route_name' => 'entity.configurable_language.edit_form',
'title' => '!label language',
'title' => '@label language',
'names' => array(),
'entity_type' => 'configurable_language',
'route_name' => 'config_translation.item.overview.entity.configurable_language.edit_form',
......
......@@ -50,7 +50,7 @@ protected function setUp() {
$definition = array(
'class' => '\Drupal\config_translation\ConfigFieldMapper',
'base_route_name' => 'entity.field_config.node_field_edit_form',
'title' => '!label field',
'title' => '@label field',
'names' => array(),
'entity_type' => 'field_config',
);
......
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