Blocking Special Characters Created with (alt + n) (PHP)
To give an example.. One day you will come across a space character created with alt + 255 passing through the trim in the space control. That's why the checks you make will not work and malicious people will send empty content. To prevent this, we need to filter such special characters with the help of a function.
function altReplace($string){
$search = array(
chr(0xC2) . chr(0xA0), // c2a0; Alt+255; Alt+0160; Alt+511; Alt+99999999;
chr(0xC2) . chr(0x90), // c290; Alt+0144
chr(0xC2) . chr(0x9D), // cd9d; Alt+0157
chr(0xC2) . chr(0x81), // c281; Alt+0129
chr(0xC2) . chr(0x8D), // c28d; Alt+0141
chr(0xC2) . chr(0x8F), // c28f; Alt+0143
chr(0xC2) . chr(0xAD), // cdad; Alt+0173
chr(0xAD)
);
$string = str_replace($search, '', $string);
return trim($string);
}
Yes, now if we use the post or get values as follows;
altReplace($_POST['test']);
altReplace($_GET['test']);
We would not encounter such problems.
Comments
Popular Articles
Popular Tags
- #directive
- #Function
- #Json
- #Class
- #SASS
- #Form
- #Redirect
- #API
- #Special Characters
- #Special
- #Random
- #Generating
- #
- #Text
- #Ajax
- #URL
- #Encrypting
- #React
- #Show
- #timeAgo
- #PSR-4
- #Hide
- #DDOS Protection
- #DDOS
- #cURL
- #Logic For Displaying Posts
- #Error
- #Key
- #General Error
- #1364 Field
- #Abbreviation
- #Blade
- #Version
- #QR
- #QR Code Generating
- #Array
- #Arrays with Key Values to String Statement
- #Short Tag
- #Activate
- #Real Time
- #Socket.io
- #301
- #Custom Directives
- #Iframe Detection
- #Date
- #Characters
- #Insert
- #Autoloader
- #Composer
- #Reading
There are no comments, make the firs comment