Danack / Params

Framework agnostic validation
MIT License
6 stars 1 forks source link

Having a "sane name character" validator would be nice. #5

Open Danack opened 6 years ago

Danack commented 6 years ago

To allow all 'letters', accents and emojis, but to exclude those that lead to: Ś͖̩͇̗̪̏̈́T ALL I​S LOST the pon̷y he comes he c̶̮omes he comes the ich​or permeates all MY FACE MY FACE ᵒh god no NO NOO̼O​O NΘ stop the an​*̶͑̾̾​̅ͫ͏̙̤g͇̫͛͆̾ͫ̑͆l͖͉̗̩̳̟̍ͫͥͨe̠̅s ͎a̧͈͖r̽̾̈́͒͑e n​ot rè̑ͧ̌aͨl̘̝̙̃ͤ͂̾̆ ZA̡͊͠͝LGΌ ISͮ̂҉̯͈͕̹̘̱ TO͇̹̺ͅƝ̴ȳ̳ TH̘Ë͖́̉ ͠P̯͍̭O̚​N̐Y̡ H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝S̨̥̫͎̭ͯ̿̔̀ͅ

// codepoints in pcre
$someEmoji = '([\x{1F602}-\x{1F64F}]+)xu';
$result = preg_match($someEmoji, "foo \u{1F602}", $matches, PREG_OFFSET_CAPTURE);

var_dump($matches);

// codepoints in php
$someEmoji = "([\u{1F602}-\u{1F64F}]+)xu";
$result = preg_match($someEmoji, "foo \u{1F602}", $matches, PREG_OFFSET_CAPTURE);
Danack commented 5 years ago

Also: https://twitter.com/pixelastic/status/1111199259678986240

I used the Right-to-Left UTF-8 character (U+200F) in my info on GitHub. Makes it easy to spot automated emails (and it's also fun to see UIs importing the data breaking)