diff --git a/core/modules/views/src/Tests/Handler/FieldUnitTest.php b/core/modules/views/src/Tests/Handler/FieldUnitTest.php index a6021ee..c24d599 100644 --- a/core/modules/views/src/Tests/Handler/FieldUnitTest.php +++ b/core/modules/views/src/Tests/Handler/FieldUnitTest.php @@ -220,11 +220,37 @@ public function testFieldTokens() { $random_text = $this->randomMachineName(); $job_field->setTestValue($random_text); $output = $job_field->advancedRender($row); - $this->assertSubString($output, $old_token, format_string('Make sure the old token style (!token => !value) is not changed in the output (!output)', [ + $this->assertEqual($output, $old_token, format_string('Make sure the old token style (!token => !value) is not changed in the output (!output)', [ '!value' => $random_text, '!output' => $output, '!token' => $job_field->options['alter']['text'], ])); + + // Verify HTML tags are allowed in rewrite templates while token + // replacements are escaped. + $job_field->options['alter']['text'] = '

{{ job }}

'; + $random_text = $this->randomMachineName(); + $job_field->setTestValue('' . $random_text . ''); + $output = $job_field->advancedRender($row); + $this->assertEqual($output, '

<span>' . $random_text . '</span>

', 'Valid tags are allowed in rewrite templates and token replacements.'); + + // Verify '; + $job_field->options['alter']['text'] = $rewrite_template; + $random_text = $this->randomMachineName(); + $job_field->setTestValue($random_text); + $output = $job_field->advancedRender($row); + $this->assertNotSubString($output, ''; + $job_field->options['alter']['text'] = $rewrite_template; + $random_text = $this->randomMachineName(); + $job_field->setTestValue($random_text); + $output = $job_field->advancedRender($row); + $this->assertEqual($output, $random_text, format_string('Make sure a script tag in the template (!template) is removed, leaving only the replaced token in the output (!output)', [ + '!output' => $output, + '!template' => $rewrite_template, + ])); } /**