source: branches/feature-module-update/data/smarty_extends/modifier.script_escape.php @ 15078

Revision 15078, 609 bytes checked in by nanasess, 17 years ago (diff)

r15064 から svn cp
とりあえず暫定コミット.

  • UTF-8 に変更
  • slib.php, glib.php のクラス化
  • LC_Page の抽象化(一部)
RevLine 
[14393]1<?php
2/**
[15078]3 * Scriptタグをエスケープする
[14393]4 *
[15078]5 * @param  string $value 入力
6 * @return string $value マッチした場合は変換後の文字列、しない場合は入力された文字列をそのまま返す。
[14393]7 */
8function smarty_modifier_script_escape($value) {
9   
[14928]10    if (is_array($value)) return $value;
[14464]11   
[14928]12    $pattern = "/<script.*?>|<\/script>|javascript:/";
13    $convert = "#script tag escaped#";
[14525]14   
[14529]15    if ( preg_match_all($pattern, $value, $matches) ) {
[14525]16        return preg_replace($pattern, $convert, $value);
17    } else {
18        return $value;
19    }
[14393]20}
21?>
Note: See TracBrowser for help on using the repository browser.