I have a quick regex question that I figured someone might know off the top of their head. What would the regex be for CakePHP's validation be if I only want to allow upper/lower alphanumber, spaces, punctuation, and quotes? This is what I have, but it's off:
'rule' => array('custom', '/[a-z0-9\x20\x21\x2E\x3A\x3B\x3F\x2C\x27\x22]{0,600}/i'),
From what I get, the a-z0-9 covers alphanumeric, but shouldn't the \xXX cover the punctuation with the ASCII hex codes? And then the {0,600] means a length of 0-600 characters, and i means upper and lower. What am I missing?
For example: valid: This is a "valid text", which contains ' and punctuation!
invalid: This is an obvious XSS attempt
No comments:
Post a Comment