- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
「データ検証」の版間の差分
細 (「高度な話題」カテゴリーを、「上級トピック」カテゴリーに変更(Advanced Topics)) |
(2.8: 非推奨となった関数、新規関数 (変更履歴参照)、未翻訳(冒頭の NeedTrans の注釈も参照)) |
||
1行目: | 1行目: | ||
+ | {{NeedTrans|一部|<br />変更点が入り組んでいて最新の英文に置き換えにくかった節には、その節の英文全てをコメントアウトで入れてあります。できれば通しで見直してみてください。}} | ||
信頼できないデータが、さまざまな情報源から入ってきます (ユーザー、第三者のサイト、あなた自身のデータベースも!…)。そして、これらすべては、入力時と出力時の両方で検証する必要があります。 | 信頼できないデータが、さまざまな情報源から入ってきます (ユーザー、第三者のサイト、あなた自身のデータベースも!…)。そして、これらすべては、入力時と出力時の両方で検証する必要があります。 | ||
11行目: | 12行目: | ||
=== HTML/XML === | === HTML/XML === | ||
− | + | <!-- | |
+ | Note that many types of XML documents (as opposed to HTML documents) understand only a few named character references: <code>apos, amp, gt, lt, quot</code>. When outputting text to such an XML document, be sure to filter any text containing illegal named entities through WordPress's <code>ent2ncr( $text )</code> function. | ||
+ | --> | ||
+ | (HTML文書に対して)多くの形式のXML文書が理解する文字実体参照は <code>&apos;</code>、<code>&amp;</code>、<code>&gt;</code>、<code>&lt;</code>、<code>&quot;</code> の5つのみであることに注意してください。テキストを XML 書類として出力するときは、不正な文字実体参照を含むあらゆるテキストを、WordPress の <code>ent2ncr( $text )</code> 関数を通してフィルターしてください。 | ||
==== HTML/XML の断片 ==== | ==== HTML/XML の断片 ==== | ||
20行目: | 24行目: | ||
==== テキスト節 ==== | ==== テキスト節 ==== | ||
− | ; <code> | + | <!-- |
− | : < | + | ; <code>esc_html( $text )</code> (since 2.8) |
+ | : Encodes <tt>< > & " '</tt> (less than, greater than, ampersand, double quote, single quote). Very similar to <code>esc_attr</code>. | ||
+ | ; <code>esc_html__</code> (since 2.8) | ||
+ | : Translates and encodes | ||
+ | ; <code>esc_html_e</code> (since 2.8) | ||
+ | : Translates, encodes, and echos | ||
+ | ; <code>wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false )</code> (deprecated since 2.8) | ||
+ | : Encodes <tt>< > &</tt> (less than, greater than, ampersand). Will never double encode entities. Since 2.8, if called with exactly 1 argument, it will encode quote characters as well (via <code>esc_html</code>), as extra protection for older plugins. | ||
; <code>htmlspecialchars( $text, ENT_NOQUOTES )</code> | ; <code>htmlspecialchars( $text, ENT_NOQUOTES )</code> | ||
− | : <, &, > をエンコードします。2回実行すると、二重にエンコードされます。 | + | : Encodes <tt>< > &</tt>. Will double encode html entities if run twice. |
+ | --> | ||
+ | ; <code>esc_html( $text )</code> (since 2.8) | ||
+ | : Encodes <tt>< > & " '</tt> (less than, greater than, ampersand, double quote, single quote). Very similar to <code>esc_attr</code>. | ||
+ | ; <code>esc_html__</code> (since 2.8) | ||
+ | : Translates and encodes | ||
+ | ; <code>esc_html_e</code> (since 2.8) | ||
+ | : Translates, encodes, and echos | ||
+ | ; <code>wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false )</code> (deprecated since 2.8) | ||
+ | : <tt><、>、&</tt> をエンコードします (less than, greater than, ampersand)。これらを二重にエンコードすることはありません。(訳注: 数値実体参照を使うため、古い携帯電話ではエンコード結果が認識されないことがあります) Since 2.8, if called with exactly 1 argument, it will encode quote characters as well (via <code>esc_html</code>), as extra protection for older plugins. | ||
+ | ; <code>htmlspecialchars( $text, ENT_NOQUOTES )</code> | ||
+ | : <tt><、>、&</tt> をエンコードします。2回実行すると、二重にエンコードされます。 | ||
+ | |||
==== 属性値 ==== | ==== 属性値 ==== | ||
− | ; <code>attribute_escape( $text )</code> ( | + | <!-- |
− | : < | + | ; <code>esc_attr</code> (since 2.8) |
+ | ; <code>attribute_escape( $text )</code> (deprecated since 2.8) | ||
+ | : Encodes <tt>< > & " '</tt> (less than, greater than, ampersand, double quote, single quote). Will never double encode entities. '''See clean_url() in [[#URLs]]''' | ||
+ | ; <code>esc_attr__</code> | ||
+ | : Translates and encodes | ||
+ | ; <code>esc_attr_e</code> | ||
+ | : Translates, encodes, and echos | ||
; <code>htmlspecialchars( $text, ENT_QUOTES )</code> | ; <code>htmlspecialchars( $text, ENT_QUOTES )</code> | ||
− | : < | + | : Encodes <tt>< > & " '</tt>. Will double encode html entities if run twice. '''See clean_url() in [[#URLs]]''' |
+ | --> | ||
+ | ; <code>esc_attr</code> (since 2.8) | ||
+ | ; <code>attribute_escape( $text )</code> (deprecated since 2.8) | ||
+ | : <tt>< > & " '</tt> をエンコードします(less than, greater than, ampersand, double quote, single quote)。これらを二重にエンコードすることはありません。'''[[#URL|URL]] の場合は clean_url() を使ってください''' (訳注: 数値実体参照を使うため、古い携帯電話ではエンコード結果が認識されないことがあります) | ||
+ | ; <code>esc_attr__</code> | ||
+ | : Translates and encodes | ||
+ | ; <code>esc_attr_e</code> | ||
+ | : Translates, encodes, and echos | ||
+ | ; <code>htmlspecialchars( $text, ENT_QUOTES )</code> | ||
+ | : <tt>< > & " '</tt> をエンコードします。2回実行すると、二重にエンコードされます。'''[[#URL|URL]] の場合は clean_url() を使ってください''' | ||
==== JavaScript ==== | ==== JavaScript ==== | ||
− | ; <code>js_escape( $text )</code> | + | <!-- |
− | : ' をエスケープし、" をエンコードします。行末を修正します。 | + | ; <code>esc_js</code> (since 2.8) |
+ | ; <code>js_escape( $text )</code> (deprecated since 2.8) | ||
+ | : Escapes <tt>'</tt>, encodes <tt>"</tt>, and fixes line endings. | ||
+ | --> | ||
+ | ; <code>esc_js</code> (since 2.8) | ||
+ | ; <code>js_escape( $text )</code> (deprecated since 2.8) | ||
+ | : <tt>'</tt> をエスケープし、<tt>"</tt> をエンコードします。行末を修正します。 | ||
=== URL === | === URL === | ||
+ | <!-- | ||
+ | ; <code>esc_url</code> (since 2.8) | ||
+ | ; <code>clean_url( $url, (array) $protocols = null, $context = 'display' )</code> | ||
+ | : Always use <code>clean_url</code> when sanitizing URLs (in text nodes, attribute nodes or anywhere else). Rejects URLs that do not have one of the provided whitelisted protocols (defaulting to <tt>http</tt>, <tt>https</tt>, <tt>ftp</tt>, <tt>ftps</tt>, <tt>mailto</tt>, <tt>news</tt>, <tt>irc</tt>, <tt>gopher</tt>, <tt>nntp</tt>, <tt>feed</tt>, and <tt>telnet</tt>), eliminates invalid characters, and removes dangerous characters. <code>$context</code> should be one of the following. | ||
+ | :; <code>display</code> : For output in an (X)HTML or XML document. Encodes ampersands (<tt>&</tt>) and single quotes (<tt>'</tt>) as numeric entity references (<tt>&, '</tt>). | ||
+ | :; <code>url</code> : strips invalid URL characters only. | ||
+ | :; <code>db</code> : use if you're about to insert into the database. | ||
+ | ; <code>esc_url_raw</code> (since 2.8) | ||
+ | : For inserting an URL in the database (just like <code>$context = "db"</code>, above) | ||
+ | ; <code>urlencode( $scalar )</code> | ||
+ | : Encodes for use in URL (as a query parameter, for example) | ||
+ | ; <code>urlencode_deep( $array )</code> | ||
+ | : urlencodes all array elements. | ||
+ | --> | ||
+ | ; <code>esc_url</code> (since 2.8) | ||
; <code>clean_url( $url, (array) $protocols = null, $context = 'display' )</code> | ; <code>clean_url( $url, (array) $protocols = null, $context = 'display' )</code> | ||
− | : URL を無害化するときは、常に <code>clean_url</code> を使ってください (テキスト中、属性値、その他あらゆる場所で) | + | : URL を無害化するときは、常に <code>clean_url</code> を使ってください (テキスト中、属性値、その他あらゆる場所で)。ホワイトリストで提供されたプロトコル(デフォルトは <tt>http</tt> ならびに <tt>https</tt>、<tt>ftp</tt>、<tt>ftps</tt>、<tt>mailto</tt>、<tt>news</tt>、<tt>irc</tt>、<tt>gopher</tt>、<tt>nntp</tt>、<tt>feed</tt>、<tt>telnet</tt>)を持たない URL は拒否し、不正な文字を排除し、危険な文字を除去します。<code>$context</code> は以下のいずれかです。 |
− | : | + | :; <code>display</code> : For output in an (X)HTML or XML document. Encodes ampersands (<tt>&</tt>) and single quotes (<tt>'</tt>) as numeric entity references (<tt>&, '</tt>). |
− | : | + | :; <code>url</code> : strips invalid URL characters only. |
− | : "db" | + | :; <code>db</code> : データベースに挿入するとき使います。 |
+ | ; <code>esc_url_raw</code> (since 2.8) | ||
+ | : For inserting an URL in the database (just like <code>$context = "db"</code>, above) | ||
; <code>urlencode( $scalar )</code> | ; <code>urlencode( $scalar )</code> | ||
− | : URL 用にエンコードします ( | + | : URL 用にエンコードします (例えば、クエリ文字列に使う場合) |
; <code>urlencode_deep( $array )</code> | ; <code>urlencode_deep( $array )</code> | ||
: すべての配列要素に urlencode を適用します。 | : すべての配列要素に urlencode を適用します。 | ||
49行目: | 111行目: | ||
: <code>$data</code> は未エスケープとしてください (この関数がエスケープしてくれます)。配列キーがカラム、配列値がデータベース値になります。 | : <code>$data</code> は未エスケープとしてください (この関数がエスケープしてくれます)。配列キーがカラム、配列値がデータベース値になります。 | ||
; <code>$wpdb->update( $table, (array) $data, (array) $where )</code> | ; <code>$wpdb->update( $table, (array) $data, (array) $where )</code> | ||
− | : <code>$data</code> は未エスケープとしてください。配列キーがカラム、配列値がデータベース値になります。<code>$where</code> | + | : <code>$data</code> は未エスケープとしてください。配列キーがカラム、配列値がデータベース値になります。<code>$where</code> は未エスケープとしてください。複数の <code>WHERE</code> 節は <code>AND</code> で連結されます。 |
$wpdb->update( | $wpdb->update( | ||
'my_table', | 'my_table', | ||
62行目: | 124行目: | ||
$status // 信頼できない整数値 (関数が無害化します) | $status // 信頼できない整数値 (関数が無害化します) | ||
) ); | ) ); | ||
+ | ; <code>esc_sql( $text )</code> (since 2.8) | ||
; <code>$wpdb->escape( $text )</code> | ; <code>$wpdb->escape( $text )</code> | ||
: SQL クエリ用に、1つの文字列をエスケープします。<code>addslashes()</code> の見せかけです。 | : SQL クエリ用に、1つの文字列をエスケープします。<code>addslashes()</code> の見せかけです。 | ||
71行目: | 134行目: | ||
=== ファイルシステム === | === ファイルシステム === | ||
; <code>validate_file( (string) $filename, (array) $allowed_files = "" )</code> | ; <code>validate_file( (string) $filename, (array) $allowed_files = "" )</code> | ||
− | : | + | <!-- |
+ | : Used to prevent directory traversal attacks, or to test a filename against a whitelist. Returns <tt>0</tt> if <code>$filename</code> represents a valid relative path. After validating, you <em>must</em> treat <code>$filename</code> as a relative path (i.e. you must prepend it with an absolute path), since something like <tt>/etc/hosts</tt> will validate with this function. Returns an integer greater than zero if the given path contains <tt>..</tt>, <tt>./</tt>, or <tt>:</tt>, or is not in the <code>$allowed_files</code> whitelist. Be careful making boolean interpretations of the result, since <tt>false</tt> (0) indicates the filename has passed validation, whereas <tt>true</tt> (> 0) indicates failure. | ||
+ | --> | ||
+ | : <!-- Used to -->ディレクトリートラバーサル攻撃を防止します, or test a filename against a whitelist. <code>$filename</code> が正当な相対パスを示すならば <code>0</code> を返します。検証後、<code>$filename</code> を相対パスとして'''扱わなければなりません (MUST)''' (例えば、ABSPATH の後に繋げる等)。なぜなら、<code>/etc/hosts</code> はこの関数で正当と判定されるからです。 Returns an integer greater than zero if the given path contains <tt>..</tt>, <tt>./</tt>, or <tt>:</tt>, or is not in the <code>$allowed_files</code> whitelist. Be careful making boolean interpretations of the result, since <tt>false</tt> (0) indicates the filename has passed validation, whereas <tt>true</tt> (> 0) indicates failure. | ||
=== HTTP ヘッダ === | === HTTP ヘッダ === | ||
146行目: | 212行目: | ||
$trusted_slug = sanitize_title( $untrusted_slug ); | $trusted_slug = sanitize_title( $untrusted_slug ); | ||
− | {{原文| | + | {{原文|Data Validation|82973}}<!-- 01:24, 13 February 2010 Bigsquaredot 版 --> |
+ | |||
+ | == 変更履歴 == | ||
+ | * [[Version 2.8|2.8]] : 次の関数が'''非推奨'''(廃止予定)となりました。右側の関数を使ってください([http://wpdevel.wordpress.com/tag/escaping/ WordPress Development Updates] より)。 | ||
+ | ** <code>clean_url()</code> → <code>esc_url()</code> | ||
+ | ** <code>sanitize_url()</code> → <code>esc_url_raw()</code> | ||
+ | ** <code>wp_specialchars()</code> → <code>esc_html()</code> (also: <code>esc_html__()</code> and <code>esc_html_e()</code>) | ||
+ | ** <code>attribute_escape()</code> → <code>esc_attr()</code> (also: <code>esc_attr__()</code> and <code>esc_attr_e()</code>) | ||
+ | |||
+ | [http://comox.textdrive.com/pipermail/wp-hackers/2009-May/026242.html wp_specialchars() vs attribute_escape() ( now esc_attr() ) and quote entity-encoding] も参照のこと。 | ||
− | {{DEFAULTSORT: | + | {{DEFAULTSORT:てえたけんしよう}} |
[[Category:上級トピック]] | [[Category:上級トピック]] | ||
[[Category:WordPress の開発]] | [[Category:WordPress の開発]] | ||
+ | [[Category:セキュリティ]]<!-- 試験的カテゴリ --> | ||
+ | [[Category:wp2.8]] | ||
− | [[en: | + | [[en:Data Validation]] |
2010年2月18日 (木) 00:35時点における版
このページ「データ検証」は一部未翻訳です。和訳や日本語情報を加筆してくださる協力者を求めています。
変更点が入り組んでいて最新の英文に置き換えにくかった節には、その節の英文全てをコメントアウトで入れてあります。できれば通しで見直してみてください。
信頼できないデータが、さまざまな情報源から入ってきます (ユーザー、第三者のサイト、あなた自身のデータベースも!…)。そして、これらすべては、入力時と出力時の両方で検証する必要があります。
目次
出力の無害化
データの無害化 (サニタイズ) する方法は、データの種類およびそれが使われる文脈 (コンテキスト) に依存します。WordPress における共通の処理と、どのように無害化すべきかを以下に示します。
整数値
-
intval( $int )
または(int) $int
- 整数値を想定するならば、キャストします。
-
absint( $int )
- 結果が非負であると保証されます
HTML/XML
(HTML文書に対して)多くの形式のXML文書が理解する文字実体参照は '
、&
、>
、<
、"
の5つのみであることに注意してください。テキストを XML 書類として出力するときは、不正な文字実体参照を含むあらゆるテキストを、WordPress の ent2ncr( $text )
関数を通してフィルターしてください。
HTML/XML の断片
-
wp_kses( (string) $fragment, (array) $allowed_html, (array) $protocols = null )
- KSES は悪意あるスクリプトを除去します。すべての信頼できない HTML (投稿文、コメント文など) は
wp_kses()
を通すべきです。使い方やデフォルト値などはwp-includes/kses.php
を見てください。 -
wp_rel_nofollow( (string) $html )
- あらゆる <a> リンクに "rel='nofollow'" 属性をつけます。
テキスト節
-
esc_html( $text )
(since 2.8) - Encodes < > & " ' (less than, greater than, ampersand, double quote, single quote). Very similar to
esc_attr
. -
esc_html__
(since 2.8) - Translates and encodes
-
esc_html_e
(since 2.8) - Translates, encodes, and echos
-
wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false )
(deprecated since 2.8) - <、>、& をエンコードします (less than, greater than, ampersand)。これらを二重にエンコードすることはありません。(訳注: 数値実体参照を使うため、古い携帯電話ではエンコード結果が認識されないことがあります) Since 2.8, if called with exactly 1 argument, it will encode quote characters as well (via
esc_html
), as extra protection for older plugins. -
htmlspecialchars( $text, ENT_NOQUOTES )
- <、>、& をエンコードします。2回実行すると、二重にエンコードされます。
属性値
-
esc_attr
(since 2.8) -
attribute_escape( $text )
(deprecated since 2.8) - < > & " ' をエンコードします(less than, greater than, ampersand, double quote, single quote)。これらを二重にエンコードすることはありません。URL の場合は clean_url() を使ってください (訳注: 数値実体参照を使うため、古い携帯電話ではエンコード結果が認識されないことがあります)
-
esc_attr__
- Translates and encodes
-
esc_attr_e
- Translates, encodes, and echos
-
htmlspecialchars( $text, ENT_QUOTES )
- < > & " ' をエンコードします。2回実行すると、二重にエンコードされます。URL の場合は clean_url() を使ってください
JavaScript
-
esc_js
(since 2.8) -
js_escape( $text )
(deprecated since 2.8) - ' をエスケープし、" をエンコードします。行末を修正します。
URL
-
esc_url
(since 2.8) -
clean_url( $url, (array) $protocols = null, $context = 'display' )
- URL を無害化するときは、常に
clean_url
を使ってください (テキスト中、属性値、その他あらゆる場所で)。ホワイトリストで提供されたプロトコル(デフォルトは http ならびに https、ftp、ftps、mailto、news、irc、gopher、nntp、feed、telnet)を持たない URL は拒否し、不正な文字を排除し、危険な文字を除去します。$context
は以下のいずれかです。-
display
- For output in an (X)HTML or XML document. Encodes ampersands (&) and single quotes (') as numeric entity references (&, ').
-
url
- strips invalid URL characters only.
-
db
- データベースに挿入するとき使います。
-
-
esc_url_raw
(since 2.8) - For inserting an URL in the database (just like
$context = "db"
, above) -
urlencode( $scalar )
- URL 用にエンコードします (例えば、クエリ文字列に使う場合)
-
urlencode_deep( $array )
- すべての配列要素に urlencode を適用します。
データベース
-
$wpdb->insert( $table, (array) $data )
-
$data
は未エスケープとしてください (この関数がエスケープしてくれます)。配列キーがカラム、配列値がデータベース値になります。 -
$wpdb->update( $table, (array) $data, (array) $where )
-
$data
は未エスケープとしてください。配列キーがカラム、配列値がデータベース値になります。$where
は未エスケープとしてください。複数のWHERE
節はAND
で連結されます。
$wpdb->update( 'my_table', array( 'status' => $untrusted_status, 'title' => $untrusted_title ), array( 'id' => 123 ) );
-
$wpdb->prepare( $format, (scalar) $value1, (scalar) $value2, ... )
-
$format
は sprintf() 形式に似た文字列です。%s
と%d
のみ理解します。どちらもクォート文字で囲む必要はありません。
$wpdb->get_var( $wpdb->prepare( "SELECT something FROM table WHERE foo = %s and status = %d", $name, // 未エスケープの文字列 (関数が無害化します) $status // 信頼できない整数値 (関数が無害化します) ) );
-
esc_sql( $text )
(since 2.8) -
$wpdb->escape( $text )
- SQL クエリ用に、1つの文字列をエスケープします。
addslashes()
の見せかけです。 -
$wpdb->escape_by_ref( &$text )
- 返り値はありません。
-
like_escape( $string )
- SQL クエリの LIKE 式用に
$string
を無害化します。さらに SQL エスケープする必要があります (上記のいずれかの関数を使う)。
ファイルシステム
-
validate_file( (string) $filename, (array) $allowed_files = "" )
- ディレクトリートラバーサル攻撃を防止します, or test a filename against a whitelist.
$filename
が正当な相対パスを示すならば0
を返します。検証後、$filename
を相対パスとして扱わなければなりません (MUST) (例えば、ABSPATH の後に繋げる等)。なぜなら、/etc/hosts
はこの関数で正当と判定されるからです。 Returns an integer greater than zero if the given path contains .., ./, or :, or is not in the$allowed_files
whitelist. Be careful making boolean interpretations of the result, since false (0) indicates the filename has passed validation, whereas true (> 0) indicates failure.
HTTP ヘッダ
ヘッダ分割攻撃は、HTTP クライアントに依存するため、やっかいなものです。 WordPress は、HTTP ヘッダにユーザーが生成した内容を含む必要はほとんどありませんが、それを行うならば、WordPress は HTTP ヘッダの多くにホワイトリストを用います。
WordPress は、HTTP のロケーションヘッダにユーザーが生成した内容を使えますが、以下のように無害化できます。
-
wp_redirect($location, $status = 302)
- あらゆる URL に対する安全なリダイレクト方法です。結果の HTTP ロケーションヘッダが妥当であることを保証します。
-
wp_safe_redirect($location, $status = 302)
- さらに安全です。ホワイトリストにあるドメインしかリダイレクトしません。
入力の検証
出力の無害化に挙げられた多くの関数は、入力の検証にも使えます。 さらに、WordPress は以下の関数を使っています。
スラッグ
-
sanitize_title( $title )
- 投稿スラッグなどに使われています。
-
sanitize_user( $username, $strict = false )
- 新規ユーザーを作成するときは
$strict
を使ってください (API でユーザー追加するとき)。
HTML
-
balanceTags( $html )
またはforce_balance_tags( $html )
- 正当な XML 出力になるよう、HTML タグの開き/閉じの釣り合いを取ります。
-
tag_escape( $html_tag_name )
- HTML タグ名を無害化します (関数名と違って、エスケープは何もしません)。
-
is_email( $email_address )
- 真偽値を返します
配列
-
array_map( 'absint', $array )
- 配列要素がすべて非負であることを保証します。あなたのデータに合うようにコールバック関数を入れ替えてください。
検証の哲学
検証をどのように行うか、いくつか異なった哲学があります。どれが正しいかは筋書によって異なります。
ホワイトリスト
既知および信頼された値の一覧にあるデータのみ受理します。
$possible_values = array( 'a', 1, 'good' ); if ( !in_array( $untrusted, $possible_values ) ) die( "やっちゃダメ!" ); // ここで break 文と default アクションに着目 switch ( $untrusted ) { case 'a' : ... break; ... default : die( "ろくでなし!" ); }
ブラックリスト
既知の信頼できない値の一覧にあるデータを拒否します。これがよい方法であることは、めったにありません。
書式で検出
データが正しい書式であるかテストします。正しい場合のみ受理します。
if ( !ctype_alnum( $data ) ) die( "あなたのデータは※△□%&〒☆" ); if ( preg_match( "/[^0-9.-]/", $data ) ) die( "浮動小数じゃない? おバカ!" );
書式で訂正
ほとんどのデータを受理し、危険な部分を除去または変更します。
$trusted_integer = (int) $untrusted_integer; $trusted_alpha = preg_replace( '/[^a-z]/i', "", $untrusted_alpha ); $trusted_slug = sanitize_title( $untrusted_slug );
最新英語版: WordPress Codex » Data Validation (最新版との差分)
変更履歴
- 2.8 : 次の関数が非推奨(廃止予定)となりました。右側の関数を使ってください(WordPress Development Updates より)。
-
clean_url()
→esc_url()
-
sanitize_url()
→esc_url_raw()
-
wp_specialchars()
→esc_html()
(also:esc_html__()
andesc_html_e()
) -
attribute_escape()
→esc_attr()
(also:esc_attr__()
andesc_attr_e()
)
-
wp_specialchars() vs attribute_escape() ( now esc_attr() ) and quote entity-encoding も参照のこと。