Problem/Motivation

Searched using

ag "label\(\)" | grep -v "js" | grep -v "css" | grep -v "vendor" | grep -v "twig" | grep -v "yml" | grep "!"

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

dawehner created an issue. See original summary.

dawehner’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new3.78 KB

Status: Needs review » Needs work

The last submitted patch, 2: 2568781-2.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new8 KB
new6.11 KB

There we go, this is a bit tricky but some of those are just stupid, like t() around already translated values.

Status: Needs review » Needs work

The last submitted patch, 4: 2568781-4.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new8.01 KB
new911 bytes

Another missed space.

The last submitted patch, 2: 2568781-2.patch, failed testing.

dawehner’s picture

Assigned: dawehner » Unassigned

Yeah its green.

The last submitted patch, 4: 2568781-4.patch, failed testing.

alexpott’s picture

Status: Needs review » Needs work
  1. +++ b/core/lib/Drupal/Core/Menu/menu.api.php
    @@ -388,7 +388,7 @@ function hook_contextual_links_alter(array &$links, $group, array $route_paramet
    -    $links['menu_edit']['title'] = t('Edit menu: !label', array('!label' => $menu->label()));
    +    $links['menu_edit']['title'] = t('Edit menu: @label', array('@label' => $menu->label()));
    

    Menu labels are escaped when they are displayed in menus so they definitely should be here.

  2. +++ b/core/modules/aggregator/src/FeedViewBuilder.php
    @@ -114,7 +114,7 @@ public function buildComponents(array &$build, array $entities, array $displays,
    -          '#title' => t('!title feed', array('!title' => $entity->label())),
    +          '#title' => t('@title feed', array('@title' => $entity->label())),
    

    So here we are saved by the current behaviour of !placeholder as $entity->label() is not marked safe before doing this. If we had the Drupal 7 behaviour this would be exploitable. Therefore I think we need to ensure there is test coverage for this in the aggregator module. I think escaping is the correct behaviour for aggregator titles.

  3. +++ b/core/modules/config_translation/src/FormElement/FormElementBase.php
    @@ -100,8 +100,8 @@ protected function getSourceElement(LanguageInterface $source_language, $source_
    -      '#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(),
    
    @@ -162,8 +162,8 @@ protected function getSourceElement(LanguageInterface $source_language, $source_
    -      '#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'],
    

    Wowzer!?!?! this was using t() as a way to mark safe. And I agree that the definition label should be escaped.

  4. +++ b/core/modules/config_translation/src/Tests/ConfigTranslationOverviewTest.php
    @@ -116,8 +117,8 @@ public function testMapperListPage() {
    -      $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);
    

    Nice we have some test coverage.

Setting to needs work for adding test coverage of the aggregator entity label in the feed icon.

lauriii’s picture

Assigned: Unassigned » lauriii

Working on the test coverage

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new9.18 KB
new2.19 KB

I tried to implement some test helper for that, but yeah xpath is stupid and HTML cannot be properly parsed by HTML

  /**
   * Assertion helper to check the raw content of a specific tag.
   *
   * This is needed because xpath html decodes stuff.
   */
  protected function assertRawTag($expected_html, $tag, array $classes = []) {
    $attributes = '';
    if ($classes) {
      $attributes = '.*class="' . implode(' ', $classes) . '".*';
    }
    preg_match("@<$tag " . $attributes . ">([^<]*)</$tag>@", str_replace(["\n", "\r"], '', $this->getRawContent()), $matches);
    debug("@<$tag " . $attributes . ">([^<]*)</$tag>@");
    debug($matches);

    debug($matches[1]);
  }
lauriii’s picture

Assigned: lauriii » Unassigned
lauriii’s picture

Status: Needs review » Reviewed & tested by the community

Patch looks good and RTBCing with a help of #10. Btw interdiff has code which is not included in the patch so don't get confused of that :)

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 12: 2568781-11.patch, failed testing.

The last submitted patch, 12: 2568781-11.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new9.25 KB
new781 bytes

Ups.

alexpott’s picture

stefan.r’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/core/modules/config_translation/config_translation.module
@@ -8,6 +8,7 @@
+use Drupal\Core\StringTranslation\TranslationWrapper;

Unneeded?

+++ b/core/modules/config_translation/config_translation.module
@@ -115,7 +116,7 @@ function config_translation_config_translation_info(&$info) {
+          'title' => '@label field',

+++ b/core/modules/config_translation/src/ConfigEntityMapper.php
@@ -154,11 +154,7 @@ public function setEntity(ConfigEntityInterface $entity) {
+    return $this->entity->label() . ' ' . $this->pluginDefinition['title'];

where does @label come from here? In https://www.drupal.org/files/issues/interdiff-120-122.txt I thought it was set in ConfigEntityMapper::getTitle?

Otherwise this all looks good to me

stefan.r’s picture

Status: Reviewed & tested by the community » Needs review

Oops, didn't mean to RTBC yet, just wondering about the @label field bit?

dawehner’s picture

StatusFileSize
new8.88 KB
new1.06 KB

Thank you for your review @stefan.r

Given that the @title is never used on runtime for this particular class, we could remove the line entirely.

stefan.r’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 0f6f909 and pushed to 8.0.x. Thanks!

  • alexpott committed 0f6f909 on 8.0.x
    Issue #2568781 by dawehner, lauriii, stefan.r: Replace remaining !...
alexpott’s picture

Priority: Normal » Critical

This is part of the critical meta.

alexpott’s picture

Note we've have issues with respect to entity labels going back years.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.