' ', "\n" => ' ', '!' => '!', '"' => '"', '#' => '#', '$' => '$', '%' => '%', '&' => '&', "'" => ''', '(' => '(', ')' => ')', '*' => '*', '+' => '+', ',' => ',', '.' => '.', '/' => '/', ':' => ':', ';' => ';', '<' => '<', '<⃒' => '<⃒', '=' => '=', '=⃥' => '=⃥', '>' => '>', '>⃒' => '&nvgt', '?' => '?', '@' => '@', '[' => '[', ']' => ']', '^' => '^', '_' => '_', '`' => '`', 'fj' => 'fj', '{' => '{', '|' => '|', '}' => '}', ' ' => ' ', '¡' => '¡', '¢' => '¢', '£' => '£', '¤' => '¤', '¥' => '¥', '¦' => '¦', '§' => '§', '¨' => '¨', '©' => '©', 'ª' => 'ª', '«' => '«', '¬' => '¬', '­' => '­', '®' => '®', '¯' => '¯', '°' => '°', '±' => '±', '²' => '²', '³' => '³', '´' => '´', 'µ' => 'µ', '¶' => '¶', '·' => '·', '¸' => '¸', '¹' => '¹', 'º' => 'º', '»' => '»', '¼' => '¼', '½' => '½', '¾' => '¾', '¿' => '¿', 'À' => 'À', 'Á' => 'Á', 'Â' => 'Â', 'Ã' => 'Ã', 'Ä' => 'Ä', 'Å' => 'Å', 'Æ' => 'Æ', 'Ç' => 'Ç', 'È' => 'È', 'É' => 'É', 'Ê' => 'Ê', 'Ë' => 'Ë', 'Ì' => 'Ì', 'Í' => 'Í', 'Î' => 'Î', 'Ï' => 'Ï', 'Ð' => 'Ð', 'Ñ' => 'Ñ', 'Ò' => 'Ò', 'Ó' => 'Ó', 'Ô' => 'Ô', 'Õ' => 'Õ', 'Ö' => 'Ö', '×' => '×', 'Ø' => 'Ø', 'Ù' => 'Ù', 'Ú' => 'Ú', 'Û' => 'Û', 'Ü' => 'Ü', 'Ý' => 'Ý', 'Þ' => 'Þ', 'ß' => 'ß', 'à' => 'à', 'á' => 'á', 'â' => 'â', 'ã' => 'ã', 'ä' => 'ä', 'å' => 'å', 'æ' => 'æ', 'ç' => 'ç', 'è' => 'è', 'é' => 'é', 'ê' => 'ê', 'ë' => 'ë', 'ì' => 'ì', 'í' => 'í', 'î' => 'î', 'ï' => 'ï', 'ð' => 'ð', 'ñ' => 'ñ', 'ò' => 'ò', 'ó' => 'ó', 'ô' => 'ô', 'õ' => 'õ', 'ö' => 'ö', '÷' => '÷', 'ø' => 'ø', 'ù' => 'ù', 'ú' => 'ú', 'û' => 'û', 'ü' => 'ü', 'ý' => 'ý', 'þ' => 'þ', 'ÿ' => 'ÿ', 'Ā' => 'Ā', 'ā' => 'ā', 'Ă' => 'Ă', 'ă' => 'ă', 'Ą' => 'Ą', 'ą' => 'ą', 'Ć' => 'Ć', 'ć' => 'ć', 'Ĉ' => 'Ĉ', 'ĉ' => 'ĉ', 'Ċ' => 'Ċ', 'ċ' => 'ċ', 'Č' => 'Č', 'č' => 'č', 'Ď' => 'Ď', 'ď' => 'ď', 'Đ' => 'Đ', 'đ' => 'đ', 'Ē' => 'Ē', 'ē' => 'ē', 'Ė' => 'Ė', 'ė' => 'ė', 'Ę' => 'Ę', 'ę' => 'ę', 'Ě' => 'Ě', 'ě' => 'ě', 'Ĝ' => 'Ĝ', 'ĝ' => 'ĝ', 'Ğ' => 'Ğ', 'ğ' => 'ğ', 'Ġ' => 'Ġ', 'ġ' => 'ġ', 'Ģ' => 'Ģ', 'Ĥ' => 'Ĥ', 'ĥ' => 'ĥ', 'Ħ' => 'Ħ', 'ħ' => 'ħ', 'Ĩ' => 'Ĩ', 'ĩ' => 'ĩ', 'Ī' => 'Ī', 'ī' => 'ī', 'Į' => 'Į', 'į' => 'į', 'İ' => 'İ', 'ı' => 'ı', 'IJ' => 'IJ', 'ij' => 'ij', 'Ĵ' => 'Ĵ', 'ĵ' => 'ĵ', 'Ķ' => 'Ķ', 'ķ' => 'ķ', 'ĸ' => 'ĸ', 'Ĺ' => 'Ĺ', 'ĺ' => 'ĺ', 'Ļ' => 'Ļ', 'ļ' => 'ļ', 'Ľ' => 'Ľ', 'ľ' => 'ľ', 'Ŀ' => 'Ŀ', 'ŀ' => 'ŀ', 'Ł' => 'Ł', 'ł' => 'ł', 'Ń' => 'Ń', 'ń' => 'ń', 'Ņ' => 'Ņ', 'ņ' => 'ņ', 'Ň' => 'Ň', 'ň' => 'ň', 'ʼn' => 'ʼn', 'Ŋ' => 'Ŋ', 'ŋ' => 'ŋ', 'Ō' => 'Ō', 'ō' => 'ō', 'Ő' => 'Ő', 'ő' => 'ő', 'Œ' => 'Œ', 'œ' => 'œ', 'Ŕ' => 'Ŕ', 'ŕ' => 'ŕ', 'Ŗ' => 'Ŗ', 'ŗ' => 'ŗ', 'Ř' => 'Ř', 'ř' => 'ř', 'Ś' => 'Ś', 'ś' => 'ś', 'Ŝ' => 'Ŝ', 'ŝ' => 'ŝ', 'Ş' => 'Ş', 'ş' => 'ş', 'Š' => 'Š', 'š' => 'š', 'Ţ' => 'Ţ', 'ţ' => 'ţ', 'Ť' => 'Ť', 'ť' => 'ť', 'Ŧ' => 'Ŧ', 'ŧ' => 'ŧ', 'Ũ' => 'Ũ', 'ũ' => 'ũ', 'Ū' => 'Ū', 'ū' => 'ū', 'Ŭ' => 'Ŭ', 'ŭ' => 'ŭ', 'Ů' => 'Ů', 'ů' => 'ů', 'Ű' => 'Ű', 'ű' => 'ű', 'Ų' => 'Ų', 'ų' => 'ų', 'Ŵ' => 'Ŵ', 'ŵ' => 'ŵ', 'Ŷ' => 'Ŷ', 'ŷ' => 'ŷ', 'Ÿ' => 'Ÿ', 'Ź' => 'Ź', 'ź' => 'ź', 'Ż' => 'Ż', 'ż' => 'ż', 'Ž' => 'Ž', 'ž' => 'ž', 'ƒ' => 'ƒ', 'Ƶ' => 'Ƶ', 'ǵ' => 'ǵ', 'ȷ' => 'ȷ', 'ˆ' => 'ˆ', 'ˇ' => 'ˇ', '˘' => '˘', '˙' => '˙', '˚' => '˚', '˛' => '˛', '˜' => '˜', '˝' => '˝', '̑' => '̑', 'Α' => 'Α', 'Β' => 'Β', 'Γ' => 'Γ', 'Δ' => 'Δ', 'Ε' => 'Ε', 'Ζ' => 'Ζ', 'Η' => 'Η', 'Θ' => 'Θ', 'Ι' => 'Ι', 'Κ' => 'Κ', 'Λ' => 'Λ', 'Μ' => 'Μ', 'Ν' => 'Ν', 'Ξ' => 'Ξ', 'Ο' => 'Ο', 'Π' => 'Π', 'Ρ' => 'Ρ', 'Σ' => 'Σ', 'Τ' => 'Τ', 'Υ' => 'Υ', 'Φ' => 'Φ', 'Χ' => 'Χ', 'Ψ' => 'Ψ', 'Ω' => 'Ω', 'α' => 'α', 'β' => 'β', 'γ' => 'γ', 'δ' => 'δ', 'ε' => 'ε', 'ζ' => 'ζ', 'η' => 'η', 'θ' => 'θ', 'ι' => 'ι', 'κ' => 'κ', 'λ' => 'λ', 'μ' => 'μ', 'ν' => 'ν', 'ξ' => 'ξ', 'ο' => 'ο', 'π' => 'π', 'ρ' => 'ρ', 'ς' => 'ς', 'σ' => 'σ', 'τ' => 'τ', 'υ' => 'υ', 'φ' => 'φ', 'χ' => 'χ', 'ψ' => 'ψ', 'ω' => 'ω', 'ϑ' => 'ϑ', 'ϒ' => 'ϒ', 'ϕ' => 'ϕ', 'ϖ' => 'ϖ', 'Ϝ' => 'Ϝ', 'ϝ' => 'ϝ', 'ϰ' => 'ϰ', 'ϱ' => 'ϱ', 'ϵ' => 'ϵ', '϶' => '϶', 'Ё' => 'Ё', 'Ђ' => 'Ђ', 'Ѓ' => 'Ѓ', 'Є' => 'Є', 'Ѕ' => 'Ѕ', 'І' => 'І', 'Ї' => 'Ї', 'Ј' => 'Ј', 'Љ' => 'Љ', 'Њ' => 'Њ', 'Ћ' => 'Ћ', 'Ќ' => 'Ќ', 'Ў' => 'Ў', 'Џ' => 'Џ', 'А' => 'А', 'Б' => 'Б', 'В' => 'В', 'Г' => 'Г', 'Д' => 'Д', 'Е' => 'Е', 'Ж' => 'Ж', 'З' => 'З', 'И' => 'И', 'Й' => 'Й', 'К' => 'К', 'Л' => 'Л', 'М' => 'М', 'Н' => 'Н', 'О' => 'О', 'П' => 'П', 'Р' => 'Р', 'С' => 'С', 'Т' => 'Т', 'У' => 'У', 'Ф' => 'Ф', 'Х' => 'Х', 'Ц' => 'Ц', 'Ч' => 'Ч', 'Ш' => 'Ш', 'Щ' => 'Щ', 'Ъ' => 'Ъ', 'Ы' => 'Ы', 'Ь' => 'Ь', 'Э' => 'Э', 'Ю' => 'Ю', 'Я' => 'Я', 'а' => 'а', 'б' => 'б', 'в' => 'в', 'г' => 'г', 'д' => 'д', 'е' => 'е', 'ж' => 'ж', 'з' => 'з', 'и' => 'и', 'й' => 'й', 'к' => 'к', 'л' => 'л', 'м' => 'м', 'н' => 'н', 'о' => 'о', 'п' => 'п', 'р' => 'р', 'с' => 'с', 'т' => 'т', 'у' => 'у', 'ф' => 'ф', 'х' => 'х', 'ц' => 'ц', 'ч' => 'ч', 'ш' => 'ш', 'щ' => 'щ', 'ъ' => 'ъ', 'ы' => 'ы', 'ь' => 'ь', 'э' => 'э', 'ю' => 'ю', 'я' => 'я', 'ё' => 'ё', 'ђ' => 'ђ', 'ѓ' => 'ѓ', 'є' => 'є', 'ѕ' => 'ѕ', 'і' => 'і', 'ї' => 'ї', 'ј' => 'ј', 'љ' => 'љ', 'њ' => 'њ', 'ћ' => 'ћ', 'ќ' => 'ќ', 'ў' => 'ў', 'џ' => 'џ', ' ' => ' ', ' ' => ' ', ' ' => ' ', ' ' => ' ', ' ' => ' ', ' ' => ' ', ' ' => ' ', ' ' => ' ', '​' => '​', '‌' => '‌', '‍' => '‍', '‎' => '‎', '‏' => '‏', '‐' => '‐', '–' => '–', '—' => '—', '―' => '―', '‖' => '‖', '‘' => '‘', '’' => '’', '‚' => '‚', '“' => '“', '”' => '”', '„' => '„', '†' => '†', '‡' => '‡', '•' => '•', '‥' => '‥', '…' => '…', '‰' => '‰', '‱' => '‱', '′' => '′', '″' => '″', '‴' => '‴', '‵' => '‵', '‹' => '‹', '›' => '›', '‾' => '‾', '⁁' => '⁁', '⁃' => '⁃', '⁄' => '⁄', '⁏' => '⁏', '⁗' => '⁗', ' ' => ' ', '  ' => '  ', '⁠' => '⁠', '⁡' => '⁡', '⁢' => '⁢', '⁣' => '⁣', '€' => '€', '⃛' => '⃛', '⃜' => '⃜', 'ℂ' => 'ℂ', '℅' => '℅', 'ℊ' => 'ℊ', 'ℋ' => 'ℋ', 'ℌ' => 'ℌ', 'ℍ' => 'ℍ', 'ℎ' => 'ℎ', 'ℏ' => 'ℏ', 'ℐ' => 'ℐ', 'ℑ' => 'ℑ', 'ℒ' => 'ℒ', 'ℓ' => 'ℓ', 'ℕ' => 'ℕ', '№' => '№', '℗' => '℗', '℘' => '℘', 'ℙ' => 'ℙ', 'ℚ' => 'ℚ', 'ℛ' => 'ℛ', 'ℜ' => 'ℜ', 'ℝ' => 'ℝ', '℞' => '℞', '™' => '™', 'ℤ' => 'ℤ', '℧' => '℧', 'ℨ' => 'ℨ', '℩' => '℩', 'ℬ' => 'ℬ', 'ℭ' => 'ℭ', 'ℯ' => 'ℯ', 'ℰ' => 'ℰ', 'ℱ' => 'ℱ', 'ℳ' => 'ℳ', 'ℴ' => 'ℴ', 'ℵ' => 'ℵ', 'ℶ' => 'ℶ', 'ℷ' => 'ℷ', 'ℸ' => 'ℸ', 'ⅅ' => 'ⅅ', 'ⅆ' => 'ⅆ', 'ⅇ' => 'ⅇ', 'ⅈ' => 'ⅈ', '⅓' => '⅓', '⅔' => '⅔', '⅕' => '⅕', '⅖' => '⅖', '⅗' => '⅗', '⅘' => '⅘', '⅙' => '⅙', '⅚' => '⅚', '⅛' => '⅛', '⅜' => '⅜', '⅝' => '⅝', '⅞' => '⅞', '←' => '←', '↑' => '↑', '→' => '→', '↓' => '↓', '↔' => '↔', '↕' => '↕', '↖' => '↖', '↗' => '↗', '↘' => '↘', '↙' => '↙', '↚' => '↚', '↛' => '↛', '↝' => '↝', '↝̸' => '↝̸', '↞' => '↞', '↟' => '↟', '↠' => '↠', '↡' => '↡', '↢' => '↢', '↣' => '↣', '↤' => '↤', '↥' => '↥', '↦' => '↦', '↧' => '↧', '↩' => '↩', '↪' => '↪', '↫' => '↫', '↬' => '↬', '↭' => '↭', '↮' => '↮', '↰' => '↰', '↱' => '↱', '↲' => '↲', '↳' => '↳', '↵' => '↵', '↶' => '↶', '↷' => '↷', '↺' => '↺', '↻' => '↻', '↼' => '↼', '↽' => '↽', '↾' => '↾', '↿' => '↿', '⇀' => '⇀', '⇁' => '⇁', '⇂' => '⇂', '⇃' => '⇃', '⇄' => '⇄', '⇅' => '⇅', '⇆' => '⇆', '⇇' => '⇇', '⇈' => '⇈', '⇉' => '⇉', '⇊' => '⇊', '⇋' => '⇋', '⇌' => '⇌', '⇍' => '⇍', '⇎' => '⇎', '⇏' => '⇏', '⇐' => '⇐', '⇑' => '⇑', '⇒' => '⇒', '⇓' => '⇓', '⇔' => '⇔', '⇕' => '⇕', '⇖' => '⇖', '⇗' => '⇗', '⇘' => '⇘', '⇙' => '⇙', '⇚' => '⇚', '⇛' => '⇛', '⇝' => '⇝', '⇤' => '⇤', '⇥' => '⇥', '⇵' => '⇵', '⇽' => '⇽', '⇾' => '⇾', '⇿' => '⇿', '∀' => '∀', '∁' => '∁', '∂' => '∂', '∂̸' => '∂̸', '∃' => '∃', '∄' => '∄', '∅' => '∅', '∇' => '∇', '∈' => '∈', '∉' => '∉', '∋' => '∋', '∌' => '∌', '∏' => '∏', '∐' => '∐', '∑' => '∑', '−' => '−', '∓' => '∓', '∔' => '∔', '∖' => '∖', '∗' => '∗', '∘' => '∘', '√' => '√', '∝' => '∝', '∞' => '∞', '∟' => '∟', '∠' => '∠', '∠⃒' => '∠⃒', '∡' => '∡', '∢' => '∢', '∣' => '∣', '∤' => '∤', '∥' => '∥', '∦' => '∦', '∧' => '∧', '∨' => '∨', '∩' => '∩', '∩︀' => '∩︀', '∪' => '∪', '∪︀' => '&cups', '∫' => '∫', '∬' => '∬', '∭' => '∭', '∮' => '∮', '∯' => '∯', '∰' => '∰', '∱' => '∱', '∲' => '∲', '∳' => '∳', '∴' => '∴', '∵' => '∵', '∶' => '∶', '∷' => '∷', '∸' => '∸', '∺' => '∺', '∻' => '∻', '∼' => '∼', '∼⃒' => '∼⃒', '∽' => '∽', '∽̱' => '∽̱', '∾' => '∾', '∾̳' => '∾̳', '∿' => '∿', '≀' => '≀', '≁' => '≁', '≂' => '≂', '≂̸' => '≂̸', '≃' => '≃', '≄' => '≄', '≅' => '≅', '≆' => '≆', '≇' => '≇', '≈' => '≈', '≉' => '≉', '≊' => '≊', '≋' => '≋', '≋̸' => '≋̸', '≌' => '≌', '≍' => '≍', '≍⃒' => '≍⃒', '≎' => '≎', '≎̸' => '≎̸', '≏' => '≏', '≏̸' => '≏̸', '≐' => '≐', '≐̸' => '≐̸', '≑' => '≑', '≒' => '≒', '≓' => '≓', '≔' => '≔', '≕' => '≕', '≖' => '≖', '≗' => '≗', '≙' => '≙', '≚' => '≚', '≜' => '≜', '≟' => '≟', '≠' => '≠', '≡' => '≡', '≡⃥' => '≡⃥', '≢' => '≢', '≤' => '≤', '≤⃒' => '≤⃒', '≥' => '≥', '≥⃒' => '≥⃒', '≦' => '≦', '≦̸' => '≦̸', '≧' => '≧', '≧̸' => '≧̸', '≨' => '≨', '≨︀' => '≨︀', '≩' => '≩', '≩︀' => '≩︀', '≪' => '≪', '≪̸' => '≪̸', '≪⃒' => '≪⃒', '≫' => '≫', '≫̸' => '≫̸', '≫⃒' => '≫⃒', '≬' => '≬', '≭' => '≭', '≮' => '≮', '≯' => '≯', '≰' => '≰', '≱' => '≱', '≲' => '≲', '≳' => '≳', '≴' => '≴', '≵' => '≵', '≶' => '≶', '≷' => '≷', '≸' => '≸', '≹' => '≹', '≺' => '≺', '≻' => '≻', '≼' => '≼', '≽' => '≽', '≾' => '≾', '≿' => '≿', '≿̸' => '≿̸', '⊀' => '⊀', '⊁' => '⊁', '⊂' => '⊂', '⊂⃒' => '⊂⃒', '⊃' => '⊃', '⊃⃒' => '⊃⃒', '⊄' => '⊄', '⊅' => '⊅', '⊆' => '⊆', '⊇' => '⊇', '⊈' => '⊈', '⊉' => '⊉', '⊊' => '⊊', '⊊︀' => '⊊︀', '⊋' => '⊋', '⊋︀' => '⊋︀', '⊍' => '⊍', '⊎' => '⊎', '⊏' => '⊏', '⊏̸' => '⊏̸', '⊐' => '⊐', '⊐̸' => '⊐̸', '⊑' => '⊑', '⊒' => '⊒', '⊓' => '⊓', '⊓︀' => '⊓︀', '⊔' => '⊔', '⊔︀' => '⊔︀', '⊕' => '⊕', '⊖' => '⊖', '⊗' => '⊗', '⊘' => '⊘', '⊙' => '⊙', '⊚' => '⊚', '⊛' => '⊛', '⊝' => '⊝', '⊞' => '⊞', '⊟' => '⊟', '⊠' => '⊠', '⊡' => '⊡', '⊢' => '⊢', '⊣' => '⊣', '⊤' => '⊤', '⊥' => '⊥', '⊧' => '⊧', '⊨' => '⊨', '⊩' => '⊩', '⊪' => '⊪', '⊫' => '⊫', '⊬' => '⊬', '⊭' => '⊭', '⊮' => '⊮', '⊯' => '⊯', '⊰' => '⊰', '⊲' => '⊲', '⊳' => '⊳', '⊴' => '⊴', '⊴⃒' => '⊴⃒', '⊵' => '⊵', '⊵⃒' => '⊵⃒', '⊶' => '⊶', '⊷' => '⊷', '⊸' => '⊸', '⊹' => '⊹', '⊺' => '⊺', '⊻' => '⊻', '⊽' => '⊽', '⊾' => '⊾', '⊿' => '⊿', '⋀' => '⋀', '⋁' => '⋁', '⋂' => '⋂', '⋃' => '⋃', '⋄' => '⋄', '⋅' => '⋅', '⋆' => '⋆', '⋇' => '⋇', '⋈' => '⋈', '⋉' => '⋉', '⋊' => '⋊', '⋋' => '⋋', '⋌' => '⋌', '⋍' => '⋍', '⋎' => '⋎', '⋏' => '⋏', '⋐' => '⋐', '⋑' => '⋑', '⋒' => '⋒', '⋓' => '⋓', '⋔' => '⋔', '⋕' => '⋕', '⋖' => '⋖', '⋗' => '⋗', '⋘' => '⋘', '⋘̸' => '⋘̸', '⋙' => '⋙', '⋙̸' => '⋙̸', '⋚' => '⋚', '⋚︀' => '⋚︀', '⋛' => '⋛', '⋛︀' => '⋛︀', '⋞' => '⋞', '⋟' => '⋟', '⋠' => '⋠', '⋡' => '⋡', '⋢' => '⋢', '⋣' => '⋣', '⋦' => '⋦', '⋧' => '⋧', '⋨' => '⋨', '⋩' => '⋩', '⋪' => '⋪', '⋫' => '⋫', '⋬' => '⋬', '⋭' => '⋭', '⋮' => '⋮', '⋯' => '⋯', '⋰' => '⋰', '⋱' => '⋱', '⋲' => '⋲', '⋳' => '⋳', '⋴' => '⋴', '⋵' => '⋵', '⋵̸' => '⋵̸', '⋶' => '⋶', '⋷' => '⋷', '⋹' => '⋹', '⋹̸' => '⋹̸', '⋺' => '⋺', '⋻' => '⋻', '⋼' => '⋼', '⋽' => '⋽', '⋾' => '⋾', '⌅' => '⌅', '⌆' => '⌆', '⌈' => '⌈', '⌉' => '⌉', '⌊' => '⌊', '⌋' => '⌋', '⌌' => '⌌', '⌍' => '⌍', '⌎' => '⌎', '⌏' => '⌏', '⌐' => '⌐', '⌒' => '⌒', '⌓' => '⌓', '⌕' => '⌕', '⌖' => '⌖', '⌜' => '⌜', '⌝' => '⌝', '⌞' => '⌞', '⌟' => '⌟', '⌢' => '⌢', '⌣' => '⌣', '⌭' => '⌭', '⌮' => '⌮', '⌶' => '⌶', '⌽' => '⌽', '⌿' => '⌿', '⍼' => '⍼', '⎰' => '⎰', '⎱' => '⎱', '⎴' => '⎴', '⎵' => '⎵', '⎶' => '⎶', '⏜' => '⏜', '⏝' => '⏝', '⏞' => '⏞', '⏟' => '⏟', '⏢' => '⏢', '⏧' => '⏧', '␣' => '␣', 'Ⓢ' => 'Ⓢ', '─' => '─', '│' => '│', '┌' => '┌', '┐' => '┐', '└' => '└', '┘' => '┘', '├' => '├', '┤' => '┤', '┬' => '┬', '┴' => '┴', '┼' => '┼', '═' => '═', '║' => '║', '╒' => '╒', '╓' => '╓', '╔' => '╔', '╕' => '╕', '╖' => '╖', '╗' => '╗', '╘' => '╘', '╙' => '╙', '╚' => '╚', '╛' => '╛', '╜' => '╜', '╝' => '╝', '╞' => '╞', '╟' => '╟', '╠' => '╠', '╡' => '╡', '╢' => '╢', '╣' => '╣', '╤' => '╤', '╥' => '╥', '╦' => '╦', '╧' => '╧', '╨' => '╨', '╩' => '╩', '╪' => '╪', '╫' => '╫', '╬' => '╬', '▀' => '▀', '▄' => '▄', '█' => '█', '░' => '░', '▒' => '▒', '▓' => '▓', '□' => '□', '▪' => '▪', '▫' => '▫', '▭' => '▭', '▮' => '▮', '▱' => '▱', '△' => '△', '▴' => '▴', '▵' => '▵', '▸' => '▸', '▹' => '▹', '▽' => '▽', '▾' => '▾', '▿' => '▿', '◂' => '◂', '◃' => '◃', '◊' => '◊', '○' => '○', '◬' => '◬', '◯' => '◯', '◸' => '◸', '◹' => '◹', '◺' => '◺', '◻' => '◻', '◼' => '◼', '★' => '★', '☆' => '☆', '☎' => '☎', '♀' => '♀', '♂' => '♂', '♠' => '♠', '♣' => '♣', '♥' => '♥', '♦' => '♦', '♪' => '♪', '♭' => '♭', '♮' => '♮', '♯' => '♯', '✓' => '✓', '✗' => '✗', '✠' => '✠', '✶' => '✶', '❘' => '❘', '❲' => '❲', '❳' => '❳', '⟈' => '⟈', '⟉' => '⟉', '⟦' => '⟦', '⟧' => '⟧', '⟨' => '⟨', '⟩' => '⟩', '⟪' => '⟪', '⟫' => '⟫', '⟬' => '⟬', '⟭' => '⟭', '⟵' => '⟵', '⟶' => '⟶', '⟷' => '⟷', '⟸' => '⟸', '⟹' => '⟹', '⟺' => '⟺', '⟼' => '⟼', '⟿' => '⟿', '⤂' => '⤂', '⤃' => '⤃', '⤄' => '⤄', '⤅' => '⤅', '⤌' => '⤌', '⤍' => '⤍', '⤎' => '⤎', '⤏' => '⤏', '⤐' => '⤐', '⤑' => '⤑', '⤒' => '⤒', '⤓' => '⤓', '⤖' => '⤖', '⤙' => '⤙', '⤚' => '⤚', '⤛' => '⤛', '⤜' => '⤜', '⤝' => '⤝', '⤞' => '⤞', '⤟' => '⤟', '⤠' => '⤠', '⤣' => '⤣', '⤤' => '⤤', '⤥' => '⤥', '⤦' => '⤦', '⤧' => '⤧', '⤨' => '⤨', '⤩' => '⤩', '⤪' => '⤪', '⤳' => '⤳', '⤳̸' => '⤳̸', '⤵' => '⤵', '⤶' => '⤶', '⤷' => '⤷', '⤸' => '⤸', '⤹' => '⤹', '⤼' => '⤼', '⤽' => '⤽', '⥅' => '⥅', '⥈' => '⥈', '⥉' => '⥉', '⥊' => '⥊', '⥋' => '⥋', '⥎' => '⥎', '⥏' => '⥏', '⥐' => '⥐', '⥑' => '⥑', '⥒' => '⥒', '⥓' => '⥓', '⥔' => '⥔', '⥕' => '⥕', '⥖' => '⥖', '⥗' => '⥗', '⥘' => '⥘', '⥙' => '⥙', '⥚' => '⥚', '⥛' => '⥛', '⥜' => '⥜', '⥝' => '⥝', '⥞' => '⥞', '⥟' => '⥟', '⥠' => '⥠', '⥡' => '⥡', '⥢' => '⥢', '⥣' => '⥣', '⥤' => '⥤', '⥥' => '⥥', '⥦' => '⥦', '⥧' => '⥧', '⥨' => '⥨', '⥩' => '⥩', '⥪' => '⥪', '⥫' => '⥫', '⥬' => '⥬', '⥭' => '⥭', '⥮' => '⥮', '⥯' => '⥯', '⥰' => '⥰', '⥱' => '⥱', '⥲' => '⥲', '⥳' => '⥳', '⥴' => '⥴', '⥵' => '⥵', '⥶' => '⥶', '⥸' => '⥸', '⥹' => '⥹', '⥻' => '⥻', '⥼' => '⥼', '⥽' => '⥽', '⥾' => '⥾', '⥿' => '⥿', '⦅' => '⦅', '⦆' => '⦆', '⦋' => '⦋', '⦌' => '⦌', '⦍' => '⦍', '⦎' => '⦎', '⦏' => '⦏', '⦐' => '⦐', '⦑' => '⦑', '⦒' => '⦒', '⦓' => '⦓', '⦔' => '⦔', '⦕' => '⦕', '⦖' => '⦖', '⦚' => '⦚', '⦜' => '⦜', '⦝' => '⦝', '⦤' => '⦤', '⦥' => '⦥', '⦦' => '⦦', '⦧' => '⦧', '⦨' => '⦨', '⦩' => '⦩', '⦪' => '⦪', '⦫' => '⦫', '⦬' => '⦬', '⦭' => '⦭', '⦮' => '⦮', '⦯' => '⦯', '⦰' => '⦰', '⦱' => '⦱', '⦲' => '⦲', '⦳' => '⦳', '⦴' => '⦴', '⦵' => '⦵', '⦶' => '⦶', '⦷' => '⦷', '⦹' => '⦹', '⦻' => '⦻', '⦼' => '⦼', '⦾' => '⦾', '⦿' => '⦿', '⧀' => '⧀', '⧁' => '⧁', '⧂' => '⧂', '⧃' => '⧃', '⧄' => '⧄', '⧅' => '⧅', '⧉' => '⧉', '⧍' => '⧍', '⧎' => '⧎', '⧏' => '⧏', '⧏̸' => '⧏̸', '⧐' => '⧐', '⧐̸' => '⧐̸', '⧜' => '⧜', '⧝' => '⧝', '⧞' => '⧞', '⧣' => '⧣', '⧤' => '⧤', '⧥' => '⧥', '⧫' => '⧫', '⧴' => '⧴', '⧶' => '⧶', '⨀' => '⨀', '⨁' => '⨁', '⨂' => '⨂', '⨄' => '⨄', '⨆' => '⨆', '⨌' => '⨌', '⨍' => '⨍', '⨐' => '⨐', '⨑' => '⨑', '⨒' => '⨒', '⨓' => '⨓', '⨔' => '⨔', '⨕' => '⨕', '⨖' => '⨖', '⨗' => '⨗', '⨢' => '⨢', '⨣' => '⨣', '⨤' => '⨤', '⨥' => '⨥', '⨦' => '⨦', '⨧' => '⨧', '⨩' => '⨩', '⨪' => '⨪', '⨭' => '⨭', '⨮' => '⨮', '⨯' => '⨯', '⨰' => '⨰', '⨱' => '⨱', '⨳' => '⨳', '⨴' => '⨴', '⨵' => '⨵', '⨶' => '⨶', '⨷' => '⨷', '⨸' => '⨸', '⨹' => '⨹', '⨺' => '⨺', '⨻' => '⨻', '⨼' => '⨼', '⨿' => '⨿', '⩀' => '⩀', '⩂' => '⩂', '⩃' => '⩃', '⩄' => '⩄', '⩅' => '⩅', '⩆' => '⩆', '⩇' => '⩇', '⩈' => '⩈', '⩉' => '⩉', '⩊' => '⩊', '⩋' => '⩋', '⩌' => '⩌', '⩍' => '⩍', '⩐' => '⩐', '⩓' => '⩓', '⩔' => '⩔', '⩕' => '⩕', '⩖' => '⩖', '⩗' => '⩗', '⩘' => '⩘', '⩚' => '⩚', '⩛' => '⩛', '⩜' => '⩜', '⩝' => '⩝', '⩟' => '⩟', '⩦' => '⩦', '⩪' => '⩪', '⩭' => '⩭', '⩭̸' => '⩭̸', '⩮' => '⩮', '⩯' => '⩯', '⩰' => '⩰', '⩰̸' => '⩰̸', '⩱' => '⩱', '⩲' => '⩲', '⩳' => '⩳', '⩴' => '⩴', '⩵' => '⩵', '⩷' => '⩷', '⩸' => '⩸', '⩹' => '⩹', '⩺' => '⩺', '⩻' => '⩻', '⩼' => '⩼', '⩽' => '⩽', '⩽̸' => '⩽̸', '⩾' => '⩾', '⩾̸' => '⩾̸', '⩿' => '⩿', '⪀' => '⪀', '⪁' => '⪁', '⪂' => '⪂', '⪃' => '⪃', '⪄' => '⪄', '⪅' => '⪅', '⪆' => '⪆', '⪇' => '⪇', '⪈' => '⪈', '⪉' => '⪉', '⪊' => '⪊', '⪋' => '⪋', '⪌' => '⪌', '⪍' => '⪍', '⪎' => '⪎', '⪏' => '⪏', '⪐' => '⪐', '⪑' => '⪑', '⪒' => '⪒', '⪓' => '⪓', '⪔' => '⪔', '⪕' => '⪕', '⪖' => '⪖', '⪗' => '⪗', '⪘' => '⪘', '⪙' => '⪙', '⪚' => '⪚', '⪝' => '⪝', '⪞' => '⪞', '⪟' => '⪟', '⪠' => '⪠', '⪡' => '⪡', '⪡̸' => '⪡̸', '⪢' => '⪢', '⪢̸' => '⪢̸', '⪤' => '⪤', '⪥' => '⪥', '⪦' => '⪦', '⪧' => '⪧', '⪨' => '⪨', '⪩' => '⪩', '⪪' => '⪪', '⪫' => '⪫', '⪬' => '⪬', '⪬︀' => '⪬︀', '⪭' => '⪭', '⪭︀' => '⪭︀', '⪮' => '⪮', '⪯' => '⪯', '⪯̸' => '⪯̸', '⪰' => '⪰', '⪰̸' => '⪰̸', '⪳' => '⪳', '⪴' => '⪴', '⪵' => '⪵', '⪶' => '⪶', '⪷' => '⪷', '⪸' => '⪸', '⪹' => '⪹', '⪺' => '⪺', '⪻' => '⪻', '⪼' => '⪼', '⪽' => '⪽', '⪾' => '⪾', '⪿' => '⪿', '⫀' => '⫀', '⫁' => '⫁', '⫂' => '⫂', '⫃' => '⫃', '⫄' => '⫄', '⫅' => '⫅', '⫅̸' => '⫅̸', '⫆' => '⫆', '⫆̸' => '⫆̸', '⫇' => '⫇', '⫈' => '⫈', '⫋' => '⫋', '⫋︀' => '⫋︀', '⫌' => '⫌', '⫌︀' => '⫌︀', '⫏' => '⫏', '⫐' => '⫐', '⫑' => '⫑', '⫒' => '⫒', '⫓' => '⫓', '⫔' => '⫔', '⫕' => '⫕', '⫖' => '⫖', '⫗' => '⫗', '⫘' => '⫘', '⫙' => '⫙', '⫚' => '⫚', '⫛' => '⫛', '⫤' => '⫤', '⫦' => '⫦', '⫧' => '⫧', '⫨' => '⫨', '⫩' => '⫩', '⫫' => '⫫', '⫬' => '⫬', '⫭' => '⫭', '⫮' => '⫮', '⫯' => '⫯', '⫰' => '⫰', '⫱' => '⫱', '⫲' => '⫲', '⫳' => '⫳', '⫽' => '⫽', '⫽⃥' => '⫽⃥', 'ff' => 'ff', 'fi' => 'fi', 'fl' => 'fl', 'ffi' => 'ffi', 'ffl' => 'ffl', '𝒜' => '𝒜', '𝒞' => '𝒞', '𝒟' => '𝒟', '𝒢' => '𝒢', '𝒥' => '𝒥', '𝒦' => '𝒦', '𝒩' => '𝒩', '𝒪' => '𝒪', '𝒫' => '𝒫', '𝒬' => '𝒬', '𝒮' => '𝒮', '𝒯' => '𝒯', '𝒰' => '𝒰', '𝒱' => '𝒱', '𝒲' => '𝒲', '𝒳' => '𝒳', '𝒴' => '𝒴', '𝒵' => '𝒵', '𝒶' => '𝒶', '𝒷' => '𝒷', '𝒸' => '𝒸', '𝒹' => '𝒹', '𝒻' => '𝒻', '𝒽' => '𝒽', '𝒾' => '𝒾', '𝒿' => '𝒿', '𝓀' => '𝓀', '𝓁' => '𝓁', '𝓂' => '𝓂', '𝓃' => '𝓃', '𝓅' => '𝓅', '𝓆' => '𝓆', '𝓇' => '𝓇', '𝓈' => '𝓈', '𝓉' => '𝓉', '𝓊' => '𝓊', '𝓋' => '𝓋', '𝓌' => '𝓌', '𝓍' => '𝓍', '𝓎' => '𝓎', '𝓏' => '𝓏', '𝔄' => '𝔄', '𝔅' => '𝔅', '𝔇' => '𝔇', '𝔈' => '𝔈', '𝔉' => '𝔉', '𝔊' => '𝔊', '𝔍' => '𝔍', '𝔎' => '𝔎', '𝔏' => '𝔏', '𝔐' => '𝔐', '𝔑' => '𝔑', '𝔒' => '𝔒', '𝔓' => '𝔓', '𝔔' => '𝔔', '𝔖' => '𝔖', '𝔗' => '𝔗', '𝔘' => '𝔘', '𝔙' => '𝔙', '𝔚' => '𝔚', '𝔛' => '𝔛', '𝔜' => '𝔜', '𝔞' => '𝔞', '𝔟' => '𝔟', '𝔠' => '𝔠', '𝔡' => '𝔡', '𝔢' => '𝔢', '𝔣' => '𝔣', '𝔤' => '𝔤', '𝔥' => '𝔥', '𝔦' => '𝔦', '𝔧' => '𝔧', '𝔨' => '𝔨', '𝔩' => '𝔩', '𝔪' => '𝔪', '𝔫' => '𝔫', '𝔬' => '𝔬', '𝔭' => '𝔭', '𝔮' => '𝔮', '𝔯' => '𝔯', '𝔰' => '𝔰', '𝔱' => '𝔱', '𝔲' => '𝔲', '𝔳' => '𝔳', '𝔴' => '𝔴', '𝔵' => '𝔵', '𝔶' => '𝔶', '𝔷' => '𝔷', '𝔸' => '𝔸', '𝔹' => '𝔹', '𝔻' => '𝔻', '𝔼' => '𝔼', '𝔽' => '𝔽', '𝔾' => '𝔾', '𝕀' => '𝕀', '𝕁' => '𝕁', '𝕂' => '𝕂', '𝕃' => '𝕃', '𝕄' => '𝕄', '𝕆' => '𝕆', '𝕊' => '𝕊', '𝕋' => '𝕋', '𝕌' => '𝕌', '𝕍' => '𝕍', '𝕎' => '𝕎', '𝕏' => '𝕏', '𝕐' => '𝕐', '𝕒' => '𝕒', '𝕓' => '𝕓', '𝕔' => '𝕔', '𝕕' => '𝕕', '𝕖' => '𝕖', '𝕗' => '𝕗', '𝕘' => '𝕘', '𝕙' => '𝕙', '𝕚' => '𝕚', '𝕛' => '𝕛', '𝕜' => '𝕜', '𝕝' => '𝕝', '𝕞' => '𝕞', '𝕟' => '𝕟', '𝕠' => '𝕠', '𝕡' => '𝕡', '𝕢' => '𝕢', '𝕣' => '𝕣', '𝕤' => '𝕤', '𝕥' => '𝕥', '𝕦' => '𝕦', '𝕧' => '𝕧', '𝕨' => '𝕨', '𝕩' => '𝕩', '𝕪' => '𝕪', '𝕫' => '𝕫', ); /** * List of never allowed regex replacements * * @var array */ protected static $_never_allowed_regex = array( // default javascript 'javascript\s*:', // default javascript '(document|(document\.)?window)\.(location|on\w*)', // Java: jar-protocol is an XSS hazard 'jar\s*:', // Mac (will not run the script, but open it in AppleScript Editor) 'applescript\s*:', // IE: https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#VBscript_in_an_image 'vbscript\s*:', // IE, surprise! 'wscript\s*:', // IE 'jscript\s*:', // IE: https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#VBscript_in_an_image 'vbs\s*:', // https://html5sec.org/#behavior 'behavior\s:', // ? 'Redirect\s+30\d', // data-attribute + base64 "([\"'])?data\s*:[^\\1]*?base64[^\\1]*?,[^\\1]*?\\1?", // remove Netscape 4 JS entities '&\s*\{[^}]*(\}\s*;?|$)', // old IE, old Netscape 'expression\s*(\(|&\#40;)', // old Netscape 'mocha\s*:', // old Netscape 'livescript\s*:', ); /** * XSS Hash - random Hash for protecting URLs. * * @var string */ protected $_xss_hash; /** * the replacement-string for not allowed strings * * @var string */ protected $_replacement = ''; /** * list of never allowed strings * * @var array */ protected $_never_allowed_str = array(); /** * list of never allowed strings, afterwards * * @var array */ protected $_never_allowed_str_afterwards = array(); /** * __construct() */ public function __construct() { $this->_never_allowed_str = array( 'document.cookie' => $this->_replacement, 'document.write' => $this->_replacement, '.parentNode' => $this->_replacement, '.innerHTML' => $this->_replacement, '-moz-binding' => $this->_replacement, '' => '-->', ' '<![CDATA[', ' '<!ENTITY', ' '<!DOCTYPE', ' '<!ATTLIST', '' => '<comment>', ); $this->_never_allowed_str_afterwards = array( 'FSCommand', 'onAbort', 'onActivate', 'onAttribute', 'onAfterPrint', 'onAfterScriptExecute', 'onAfterUpdate', 'onAnimationEnd', 'onAnimationIteration', 'onAnimationStart', 'onAriaRequest', 'onAutoComplete', 'onAutoCompleteError', 'onBeforeActivate', 'onBeforeCopy', 'onBeforeCut', 'onBeforeDeactivate', 'onBeforeEditFocus', 'onBeforePaste', 'onBeforePrint', 'onBeforeScriptExecute', 'onBeforeUnload', 'onBeforeUpdate', 'onBegin', 'onBlur', 'onBounce', 'onCancel', 'onCanPlay', 'onCanPlayThrough', 'onCellChange', 'onChange', 'onClick', 'onClose', 'onCommand', 'onCompassNeedsCalibration', 'onContextMenu', 'onControlSelect', 'onCopy', 'onCueChange', 'onCut', 'onDataAvailable', 'onDataSetChanged', 'onDataSetComplete', 'onDblClick', 'onDeactivate', 'onDeviceLight', 'onDeviceMotion', 'onDeviceOrientation', 'onDeviceProximity', 'onDrag', 'onDragDrop', 'onDragEnd', 'onDragEnter', 'onDragLeave', 'onDragOver', 'onDragStart', 'onDrop', 'onDurationChange', 'onEmptied', 'onEnd', 'onEnded', 'onError', 'onErrorUpdate', 'onExit', 'onFilterChange', 'onFinish', 'onFocus', 'onFocusIn', 'onFocusOut', 'onFormChange', 'onFormInput', 'onFullScreenChange', 'onFullScreenError', 'onGotPointerCapture', 'onHashChange', 'onHelp', 'onInput', 'onInvalid', 'onKeyDown', 'onKeyPress', 'onKeyUp', 'onLanguageChange', 'onLayoutComplete', 'onLoad', 'onLoadedData', 'onLoadedMetaData', 'onLoadStart', 'onLoseCapture', 'onLostPointerCapture', 'onMediaComplete', 'onMediaError', 'onMessage', 'onMouseDown', 'onMouseEnter', 'onMouseLeave', 'onMouseMove', 'onMouseOut', 'onMouseOver', 'onMouseUp', 'onMouseWheel', 'onMove', 'onMoveEnd', 'onMoveStart', 'onMozFullScreenChange', 'onMozFullScreenError', 'onMozPointerLockChange', 'onMozPointerLockError', 'onMsContentZoom', 'onMsFullScreenChange', 'onMsFullScreenError', 'onMsGestureChange', 'onMsGestureDoubleTap', 'onMsGestureEnd', 'onMsGestureHold', 'onMsGestureStart', 'onMsGestureTap', 'onMsGotPointerCapture', 'onMsInertiaStart', 'onMsLostPointerCapture', 'onMsManipulationStateChanged', 'onMsPointerCancel', 'onMsPointerDown', 'onMsPointerEnter', 'onMsPointerLeave', 'onMsPointerMove', 'onMsPointerOut', 'onMsPointerOver', 'onMsPointerUp', 'onMsSiteModeJumpListItemRemoved', 'onMsThumbnailClick', 'onOffline', 'onOnline', 'onOutOfSync', 'onPage', 'onPageHide', 'onPageShow', 'onPaste', 'onPause', 'onPlay', 'onPlaying', 'onPointerCancel', 'onPointerDown', 'onPointerEnter', 'onPointerLeave', 'onPointerLockChange', 'onPointerLockError', 'onPointerMove', 'onPointerOut', 'onPointerOver', 'onPointerUp', 'onPopState', 'onProgress', 'onPropertyChange', 'onRateChange', 'onReadyStateChange', 'onReceived', 'onRepeat', 'onReset', 'onResize', 'onResizeEnd', 'onResizeStart', 'onResume', 'onReverse', 'onRowDelete', 'onRowEnter', 'onRowExit', 'onRowInserted', 'onRowsDelete', 'onRowsEnter', 'onRowsExit', 'onRowsInserted', 'onScroll', 'onSearch', 'onSeek', 'onSeeked', 'onSeeking', 'onSelect', 'onSelectionChange', 'onSelectStart', 'onStalled', 'onStorage', 'onStorageCommit', 'onStart', 'onStop', 'onShow', 'onSyncRestored', 'onSubmit', 'onSuspend', 'onSynchRestored', 'onTimeError', 'onTimeUpdate', 'onTrackChange', 'onTransitionEnd', 'onToggle', 'onUnload', 'onURLFlip', 'onUserProximity', 'onVolumeChange', 'onWaiting', 'onWebKitAnimationEnd', 'onWebKitAnimationIteration', 'onWebKitAnimationStart', 'onWebKitFullScreenChange', 'onWebKitFullScreenError', 'onWebKitTransitionEnd', 'onWheel', 'seekSegmentTime', 'userid', 'datasrc', 'datafld', 'dataformatas', 'ev:handler', 'ev:event', '0;url', ); } /** * XSS Clean * * Sanitizes data so that Cross Site Scripting Hacks can be * prevented. This method does a fair amount of work but * it is extremely thorough, designed to prevent even the * most obscure XSS attempts. Nothing is ever 100% foolproof, * of course, but I haven't been able to get anything passed * the filter. * * Note: Should only be used to deal with data upon submission. * It's not something that should be used for general * runtime processing. * * @link http://channel.bitflux.ch/wiki/XSS_Prevention * Based in part on some code and ideas from Bitflux. * * @link http://ha.ckers.org/xss.html * To help develop this script I used this great list of * vulnerabilities along with a few other hacks I've * harvested from examining vulnerabilities in other programs. * * @param mixed $str input data e.g. string or array * @param bool $is_image whether the input is an image * * @return string|array|boolean boolean: will return a boolean, if the "is_image"-parameter is true * string: will return a string, if the input is a string * array: will return a array, if the input is a array */ public function xss_clean($str, $is_image = false) { if (is_array($str)) { foreach ($str as &$value) { $value = $this->xss_clean($value); } return $str; } $str = (string)$str; $strInt = (int)$str; $strFloat = (float)$str; /** @noinspection TypeUnsafeComparisonInspection */ if ( !$str || $str === null || is_bool($str) || "$strInt" == $str || is_int($str) || "$strFloat" == $str || is_float($str) ) { return $str; } // removes all non-UTF-8 characters // && // remove NULL characters (ignored by some browsers) $str = UTF8::clean($str, true, true, false); // decode the string $str = $this->decode_string($str); // and again... removes all non-UTF-8 characters $str = UTF8::clean($str, true, true, false); // capture converted string for later comparison if ($is_image === true) { $converted_string = $str; } do { $old_str = $str; $str = $this->_do($str, $is_image); } while ($old_str !== $str); /* * images are Handled in a special way * * Essentially, we want to know that after all of the character * conversion is done whether any unwanted, likely XSS, code was found. * * If not, we return TRUE, as the image is clean. * * However, if the string post-conversion does not matched the * string post-removal of XSS, then it fails, as there was unwanted XSS * code found and removed/changed during processing. */ if ($is_image === true) { /** @noinspection PhpUndefinedVariableInspection */ return ($str === $converted_string); } return $str; } /** * @param $str * @param $is_image * * @return mixed */ protected function _do($str, $is_image) { // remove strings that are never allowed $str = $this->_do_never_allowed($str); // make php tags safe for displaying $str = $this->make_php_tags_safe($str, $is_image); // corrects words before the browser will do it $str = $this->compact_exploded_javascript($str); // remove disallowed javascript calls in links, images etc. $str = $this->remove_disallowed_javascript($str); // remove evil attributes such as style, onclick and xmlns $str = $this->remove_evil_attributes($str, $is_image); // sanitize naughty HTML elements $str = $this->sanitize_naughty_html($str); // sanitize naughty JavaScript elements $str = $this->sanitize_naughty_javascript($str); // final clean up // This adds a bit of extra precaution in case // something got through the above filters. $str = $this->_do_never_allowed($str); $str = $this->_do_never_allowed_afterwards($str); return $str; } /** * decode the html-tags via "UTF8::html_entity_decode()" or the string via "UTF8::urldecode()" * * @param string $str * * @return string */ protected function decode_string($str) { if (preg_match('/<\w+.*/si', $str, $matches) === 1) { $str = preg_replace_callback( '/<\w+.*/si', array( $this, '_decode_entity', ), $str ); } else { $str = UTF8::urldecode($str); } return $str; } /** * Do Never Allowed * * @param string $str * * @return string */ protected function _do_never_allowed($str) { static $neverAllowedRegex; if (null === $neverAllowedRegex) { $neverAllowedRegex = implode('|', self::$_never_allowed_regex); } $str = str_ireplace(array_keys($this->_never_allowed_str), $this->_never_allowed_str, $str); $str = preg_replace('#' . $neverAllowedRegex . '#is', $this->_replacement, $str); return (string)$str; } /* * Makes PHP tags safe * * Note: XML tags are inadvertently replaced too: * * ', ), array( '<?', '?>', ), $str ); } return (string)$str; } /** * Compact any exploded words * * This corrects words like: j a v a s c r i p t * These words are compacted back to their correct state. * * @param string $str * * @return string */ public function compact_exploded_javascript($str) { static $wordsCache; $words = array( 'javascript', 'expression', 'vbscript', 'jscript', 'wscript', 'vbs', 'script', 'base64', 'applet', 'alert', 'document', 'write', 'cookie', 'window', 'confirm', 'prompt', 'eval', ); foreach ($words as $word) { if (!isset($wordsCache[$word])) { $word = $wordsCache[$word] = chunk_split($word, 1, '\s*'); } else { $word = $wordsCache[$word]; } // We only want to do this when it is followed by a non-word character // That way valid stuff like "dealer to" does not become "dealerto". $str = preg_replace_callback( '#(' . substr($word, 0, -3) . ')(\W)#is', array( $this, '_compact_exploded_words', ), $str ); } return (string)$str; } /** * Remove disallowed Javascript in links or img tags * We used to do some version comparisons and use of stripos(), * but it is dog slow compared to these simplified non-capturing * preg_match(), especially if the pattern exists in the string * * Note: It was reported that not only space characters, but all in * the following pattern can be parsed as separators between a tag name * and its attributes: [\d\s"\'`;,\/\=\(\x00\x0B\x09\x0C] * ... however, remove_invisible_characters() above already strips the * hex-encoded ones, so we'll skip them below. * * @param string $str * * @return string */ public function remove_disallowed_javascript($str) { do { $original = $str; if (preg_match('/]+([^>]*?)(?:>|$)#i', array( $this, '_js_link_removal', ), $str ); } if (preg_match('/]*?)(?:\s?/?>|$)#i', array( $this, '_js_img_removal', ), $str ); } if (preg_match('/script|xss/i', $str)) { $str = preg_replace('##si', $this->_replacement, $str); } } while ($original !== $str); return (string)$str; } /** * Remove Evil HTML Attributes (like event handlers and style) * * It removes the evil attribute and either: * * - Everything up until a space. For example, everything between the pipes: * * * * * * - Everything inside the quotes. For example, everything between the pipes: * * * * * * @param string $str The string to check * @param bool $is_image Whether the input is an image * * @return string The string with the evil attributes removed */ public function remove_evil_attributes($str, $is_image) { // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Event_Handlers $evil_attributes = array( 'on\w*', 'style', 'xmlns', 'formaction', 'form', 'xlink:href', 'seekSegmentTime', 'FSCommand', 'eval', ); if ($is_image === true) { /* * Adobe Photoshop puts XML metadata into JFIF images, * including namespacing, so we have to allow this for images. */ unset($evil_attributes[array_search('xmlns', $evil_attributes, true)]); } $evil_attributes_string = implode('|', $evil_attributes); do { $count = $temp_count = 0; // replace occurrences of illegal attribute strings with quotes (042 and 047 are octal quotes) $str = preg_replace('/(<[^>]+)(?_replacement, $str, -1, $temp_count); $count += $temp_count; // find occurrences of illegal attribute strings without quotes $str = preg_replace('/(<[^>]+)(?]*)/is', '$1' . $this->_replacement, $str, -1, $temp_count); $count += $temp_count; } while ($count); return (string)$str; } /** * Sanitize naughty HTML elements * * If a tag containing any of the words in the list * below is found, the tag gets converted to entities. * * So this: * Becomes: <blink> * * @param string $str * * @return string */ public function sanitize_naughty_html($str) { $naughty = 'alert|prompt|confirm|applet|audio|basefont|base|behavior|bgsound|blink|body|embed|expression|form|frameset|frame|head|html|ilayer|iframe|input|button|select|isindex|layer|link|meta|keygen|object|plaintext|style|script|textarea|title|math|video|svg|xml|xss|eval'; $str = preg_replace_callback( '#<(/*\s*)(' . $naughty . ')([^><]*)([><]*)#is', array( $this, '_sanitize_naughty_html', ), $str ); return (string)$str; } /** * Sanitize naughty scripting elements * * Similar to above, only instead of looking for * tags it looks for PHP and JavaScript commands * that are disallowed. Rather than removing the * code, it simply converts the parenthesis to entities * rendering the code un-executable. * * For example: eval('some code') * Becomes: eval('some code') * * @param string $str * * @return string */ public function sanitize_naughty_javascript($str) { $str = preg_replace( '#(alert|eval|prompt|confirm|cmd|passthru|eval|exec|expression|system|fopen|fsockopen|file|file_get_contents|readfile|unlink)(\s*)\((.*?)\)#si', '\\1\\2(\\3)', $str ); return (string)$str; } /** * Do Never Allowed Afterwards * * clean-up also some string, also if there is no html-tag * * @param string $str * * @return string */ protected function _do_never_allowed_afterwards($str) { static $neverAllowedStrAfterwardsRegex; if (null === $neverAllowedStrAfterwardsRegex) { foreach ($this->_never_allowed_str_afterwards as &$neverAllowedStr) { $neverAllowedStr .= '.*='; } unset($neverAllowedStr); $neverAllowedStrAfterwardsRegex = implode('|', $this->_never_allowed_str_afterwards); } $str = preg_replace('#' . $neverAllowedStrAfterwardsRegex . '#isU', $this->_replacement, $str); return (string)$str; } /** * set the replacement-string for not allowed strings * * @param string $string */ public function setReplacement($string) { $this->_replacement = (string)$string; } /** * Compact Exploded Words * * Callback method for xss_clean() to remove whitespace from * things like 'j a v a s c r i p t'. * * @param array $matches * * @return string */ protected function _compact_exploded_words($matches) { return preg_replace('/\s+/', '', $matches[1]) . $matches[2]; } /** * Sanitize Naughty HTML * * Callback method for AntiXSS->sanitize_naughty_html() to remove naughty HTML elements. * * @param array $matches * * @return string */ protected function _sanitize_naughty_html($matches) { return '<' . $matches[1] . $matches[2] . $matches[3] // encode opening brace // encode captured opening or closing brace to prevent recursive vectors: . str_replace( array( '>', '<', ), array( '>', '<', ), $matches[4] ); } /** * JS Image Removal * * Callback method for xss_clean() to sanitize image tags. * * This limits the PCRE backtracks, making it more performance friendly * and prevents PREG_BACKTRACK_LIMIT_ERROR from being triggered in * PHP 5.2+ on image tag heavy strings. * * @param array $match * * @return string */ protected function _js_img_removal($match) { return $this->_js_removal($match, 'src'); } /** * JS Removal * * Callback method for xss_clean() to sanitize tags. * * This limits the PCRE backtracks, making it more performance friendly * and prevents PREG_BACKTRACK_LIMIT_ERROR from being triggered in * PHP 5.2+ on image tag heavy strings. * * @param array $match * @param string $search * * @return string */ protected function _js_removal($match, $search) { if (!$match[0]) { return ''; } $replacer = preg_replace( '#' . $search . '=.*?(?:(?:alert|prompt|confirm)(?:\((\')*|&\#40;)|javascript:|livescript:|wscript:|vbscript:|mocha:|charset=|window\.|document\.|\.cookie|_filter_attributes(str_replace(array('<', '>',), '', $match[1])) ); return str_ireplace($match[1], $replacer, $match[0]); } /** * Filter Attributes * * Filters tag attributes for consistency and safety. * * @param string $str * * @return string */ protected function _filter_attributes($str) { if ($str === '') { return ''; } $out = ''; if (preg_match_all('#\s*[a-z\-]+\s*=\s*(\042|\047)([^\\1]*?)\\1#i', $str, $matches)) { foreach ($matches[0] as $match) { $out .= preg_replace('#/\*.*?\*/#s', '', $match); } } return $out; } /** * JS Link Removal * * Callback method for xss_clean() to sanitize links. * * This limits the PCRE backtracks, making it more performance friendly * and prevents PREG_BACKTRACK_LIMIT_ERROR from being triggered in * PHP 5.2+ on link-heavy strings. * * @param array $match * * @return string */ protected function _js_link_removal($match) { return $this->_js_removal($match, 'href'); } /** * HTML Entity Decode Callback * * @param array $match * * @return string */ protected function _decode_entity($match) { $hash = $this->xss_hash(); // protect GET variables in URLs // 901119URL5918AMP18930PROTECT8198 $match = preg_replace('|\&([a-z\_0-9\-]+)\=([a-z\_0-9\-/]+)|i', $hash . '\\1=\\2', $match[0]); // un-protect URL GET vars return str_replace($this->xss_hash(), '&', $this->_entity_decode($match)); } /** * XSS Hash * * Generates the XSS hash if needed and returns it. * * @return string XSS hash */ public function xss_hash() { if ($this->_xss_hash === null) { $rand = Bootup::get_random_bytes(16); if (!$rand) { $this->_xss_hash = md5(uniqid(mt_rand(), true)); } else { $this->_xss_hash = bin2hex($rand); } } return $this->_xss_hash; } /** * @param $str * * @return string */ protected function _entity_decode($str) { static $entities; $flags = Bootup::is_php('5.4') ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES; // decode if (strpos($str, $this->xss_hash()) !== false) { $str = UTF8::html_entity_decode($str, $flags); } else { $str = UTF8::urldecode($str); } // decode-again, for e.g. HHVM, PHP 5.3, miss configured applications ... if (preg_match_all('/&[a-z]{2,}[;]{0}/i', $str, $matches)) { if (null === $entities) { // links: // - http://dev.w3.org/html5/html-author/charref // - http://www.w3schools.com/charsets/ref_html_entities_n.asp $entitiesSecurity = array( '�' => '', '�' => '', '' => '', '' => '', '>⃒' => '', '' => '', '' => '', '­' => '', '­' => '', '­' => '', ':' => ':', ':' => ':', ':' => ':', '(' => '(', '(' => '(', '(' => '(', ')' => ')', ')' => ')', ')' => ')', '?' => '?', '?' => '?', '?' => '?', '/' => '/', '/' => '/', '/' => '/', ''' => '\'', ''' => '\'', ''' => '\'', '\' => '\\', '\' => '\\', '\' => '\\', ',' => ',', ',' => ',', ',' => ',', '.' => '.', '.' => '.', '"' => '"', '"' => '"', '"' => '"', '"' => '"', '`' => '`', '`' => '`', '`' => '`', '`' => '`', '.' => '.', '=' => '=', '=' => '=', '=' => '=', '&newline;' => "\n", ' ' => "\n", ' ' => "\n", '&tab;' => "\t", ' ' => "\n", ' ' => "\n", ); $entitiesTmp = get_html_translation_table(HTML_ENTITIES, $flags); $entitiesTmp = array_merge(self::$entitiesFallback, $entitiesTmp); $entities = array_merge( $entitiesSecurity, array_map('strtolower', array_flip($entitiesTmp)) ); } $replace = array(); $matches = array_unique(array_map('strtolower', $matches[0])); foreach ($matches as $match) { $match .= ';'; if (array_key_exists($match, $entities) === true) { $replace[$match] = $entities[$match]; } } if (count($replace) > 0) { $str = str_ireplace(array_keys($replace), array_values($replace), $str); } } return $str; } }