source:
branches/version-2_12-dev/data/smarty_extends/modifier.script_escape.php
@
21514
| Revision 21514, 572 bytes checked in by Seasoft, 14 years ago (diff) | |
|---|---|
|
|
| Line | |
|---|---|
| 1 | <?php |
| 2 | /** |
| 3 | * Scriptタグをエスケープする |
| 4 | * |
| 5 | * @param string $value 入力 |
| 6 | * @return string $value マッチした場合は変換後の文字列、しない場合は入力された文字列をそのまま返す。 |
| 7 | */ |
| 8 | function smarty_modifier_script_escape($value) { |
| 9 | |
| 10 | if (is_array($value)) return $value; |
| 11 | |
| 12 | $pattern = "/<script.*?>|<\/script>|javascript:/i"; |
| 13 | $convert = '#script tag escaped#'; |
| 14 | |
| 15 | if (preg_match_all($pattern, $value, $matches)) { |
| 16 | return preg_replace($pattern, $convert, $value); |
| 17 | } else { |
| 18 | return $value; |
| 19 | } |
| 20 | } |
Note: See TracBrowser
for help on using the repository browser.
