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
- #React
- #Class
- #centOS
- #Json
- #Text
- #API
- #URL
- #Encrypting
- #Redirect
- #Form
- #Special Characters
- #Special
- #Random
- #Generating
- #SASS
- #Version
- #Installation
- #Show
- #
- #Ajax
- #method
- #Logic For Displaying Posts
- #Key
- #DDOS
- #Default Value
- #Comment Line
- #1364 Field
- #Error
- #Abbreviation
- #QR Code Generating
- #Date
- #timeAgo
- #cURL
- #Array
- #Arrays with Key Values to String Statement
- #Short Tag
- #Vite
- #Reading Excel Files
- #Activate
- #Reading
- #Composer
- #Autoloader
- #PSR-4
- #Insert
- #Record
- #Real Time
- #Characters
- #Socket.io
There are no comments, make the firs comment