Problem/Motivation

The url is currently created by concating strings.

    if (!empty($components['url'])) {
      $name = new FormattableMarkup('<a href=":link">' . $name . '</a>', [
        ':link' => $components['url']->toString(),
      ]);
    }

Steps to reproduce

Proposed resolution

$name = $this->parser->parse($components, $format_string, $this->settings);
$safe_name = $name instanceof MarkupInterface ? $name : Html::escape((string) $name);
if (!empty($components['url'])) {
  $name = new FormattableMarkup('<a href=":link">@name</a>', [
    ':link' => $components['url']->toString(),
    '@name' => $safe_name,
  ]);
}

Remaining tasks

Add a regression test that pushes <script>alert(1)</script> through NameFormatter::viewElements() and asserts it's sanitized.

User interface changes

API changes

Data model changes

Issue fork name-3586336

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

bluegeek9 created an issue. See original summary.

bluegeek9’s picture

Issue summary: View changes
bluegeek9’s picture

Assigned: Unassigned » bluegeek9

  • bluegeek9 committed bb1effdd on 8.x-1.x
    feat: #3586336 NameFormatterService: Harden
    
bluegeek9’s picture

Assigned: bluegeek9 » Unassigned
Status: Active » Fixed
//www.flaticon.com/free-icons/thank-you Thank you for your contribution! Your continued support makes this project sustainable.
There are multiple ways to show appreciation for the work contributed to this project including:

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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