-
-
Save nowa75/c0d575d96ce6f2bacc9a to your computer and use it in GitHub Desktop.
Revisions
-
Joost van Veen created this gist
Mar 3, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ <?php /** * Filter input based on a whitelist. This filter strips out all characters that * are NOT: * - letters * - numbers * - Textile Markup special characters. * * Textile markup special characters are: * _-.*#;:|!"+%{}@ * * This filter will also pass cyrillic characters, and characters like é and ë. * * Typical usage: * $string = '_ - . * # ; : | ! " + % { } @ abcdefgABCDEFG12345 éüртхцчшщъыэюьЁуфҐ ' . "\nAnd another line!"; * echo textile_sanitize($string); * * @param string $string * @return string The sanitized string * @author Joost van Veen */ function textile_sanitize($string){ $whitelist = '/[^a-zA-Z0-9а-яА-ЯéüртхцчшщъыэюьЁуфҐ \.\*\+\\n|#;:!"%@{} _-]/'; return preg_replace($whitelist, '', $string); }