Created
June 6, 2020 09:19
-
-
Save huuyafwww/1b50f5604493addb1b2391b83d764bb1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <pre> | |
| <?php | |
| /** | |
| * All of the Arguments do Sanitize | |
| * | |
| * @param string|array $__stringer | |
| * @return string|array | |
| */ | |
| function __h( | |
| &$__stringer | |
| ) | |
| { | |
| if( | |
| is_array($__stringer) | |
| || | |
| !$__stringer = htmlspecialchars($__stringer) | |
| ) | |
| { | |
| foreach( | |
| $__stringer | |
| as | |
| &$__string | |
| ) | |
| { | |
| $__string = htmlspecialchars($__string); | |
| } | |
| } | |
| } | |
| $str_array = [ | |
| "<h1>H1です🤗</h1>" | |
| ]; | |
| $str = "<h1>H1です🤗</h1>"; | |
| __h($str); | |
| __h($str_array); | |
| print_r($str); | |
| print_r($str_array); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
活用方法としては、
__h($_POST);や__h($_GET);のようにリクエストbodyのすべてにサニタイズを行うような事象。
また
$_POSTや$_GETはグローバルスコープなため、上記を実行した後にスコープ外でもサニタイズされたリクエストbodyのまま評価することが可能になる