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
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
Comment #2
bluegeek9 commentedComment #3
bluegeek9 commentedComment #6
bluegeek9 commented