source: branches/version-2_12-dev/data/smarty_extends/modifier.script_escape.php @ 22567

Revision 22567, 572 bytes checked in by shutta, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.12.4)
Zend Framework PHP 標準コーディング規約のコーディングスタイルへ準拠。
classおよびfunctionの開始波括弧「{」のスタイルを修正。

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/**
3 * Scriptタグをエスケープする
4 *
5 * @param  string $value 入力
6 * @return string $value マッチした場合は変換後の文字列、しない場合は入力された文字列をそのまま返す。
7 */
8function smarty_modifier_script_escape($value)
9{
10
11    if (is_array($value)) return $value;
12
13    $pattern = "/<script.*?>|<\/script>|javascript:/i";
14    $convert = '#script tag escaped#';
15
16    if (preg_match_all($pattern, $value, $matches)) {
17        return preg_replace($pattern, $convert, $value);
18    } else {
19        return $value;
20    }
21}
Note: See TracBrowser for help on using the repository browser.