Skip to content

Commit

Permalink
id 属性がサニタイズされていたのを修正
Browse files Browse the repository at this point in the history
id 属性が重複するとよろしくないが、厳密にサニタイズするよりも後方互換
性を優先する
  • Loading branch information
nanasess committed Nov 23, 2024
1 parent 016c309 commit 1cc9481
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions data/smarty_extends/modifier.script_escape.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function smarty_modifier_script_escape($value)
// 念のために HTMLPurifier でサニタイズ
$config = HTMLPurifier_Config::createDefault();
$config->set('Cache.SerializerPath', __DIR__ . '/../cache');
$config->set('Attr.EnableID', true); // id 属性はサニタイズしない
$purify = new HTMLPurifier($config);

return $purify->purify($value ?? '');
Expand Down
2 changes: 1 addition & 1 deletion tests/class/modifier/Modifier_ScriptEscapeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function scriptEscapeProvider()
public function scriptNoEscapeProvider()
{
return [
['<p>test</p>', '<p>test</p>'],
['<p id="test" class="test">test</p>', '<p id="test" class="test">test</p>'],
['<input type="button">', ''], // 許可タグではないのでHTMLPurifier によって完全に削除される
['<p>onclick</p>', '<p>onclick</p>'],
['<div>test</div>', '<div>test</div>'],
Expand Down

0 comments on commit 1cc9481

Please sign in to comment.