Skip to content

Commit

Permalink
TokenSmartyTest - Add more coverage re: HTML escaping of data
Browse files Browse the repository at this point in the history
  • Loading branch information
totten committed Dec 30, 2021
1 parent e8d1234 commit 95df89a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/phpunit/CRM/Core/TokenSmartyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,21 @@ public function getDateFormats(): array {
];
}

public function testTokenDataEscape() {
$cutesyContactId = $this->individualCreate([
'first_name' => 'Ivan\'s "The Ter<r>ible"',
]);
$rendered = CRM_Core_TokenSmarty::render(
[
'msg_html' => 'First name is <b>{contact.first_name}</b>.',
'msg_text' => 'First name is __{contact.first_name}__.',
],
['contactId' => $cutesyContactId]
);
$this->assertEquals('First name is <b>Ivan&#039;s &quot;The Ter&lt;r&gt;ible&quot;</b>.', $rendered['msg_html']);
$this->assertEquals('First name is __Ivan\'s "The Ter<r>ible"__.', $rendered['msg_text']);
}

/**
* Someone malicious gives cutesy expressions (via token-content) that tries to provoke extra evaluation.
*/
Expand Down

0 comments on commit 95df89a

Please sign in to comment.