I'm currently being 'spammed' with zalgo text on my webpage and i need a function to check if it contains zalgo.

I found this code:

if ( preg_match ( '/[^\x20-\x7E]/', $text ) || preg_match ( '/[^\x20-\x7E]/', $text ) ) {
die('ZALGO not allowed');}

but it also blocks some legit posts. Is there a better way?

Thanks

有帮助吗?

解决方案

Zalgo typically falls in the CC and CD unicode ranges. Try matching against /[\xCC\xCD]/. You should generally have a reCAPTCHA anyway to mitigate spam. If it's not 4channers one day then it might be viagra bots the next day.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top