How to “Validate” Human Names in CakePHP?

后端 未结 4 505
梦谈多话
梦谈多话 2020-11-28 16:06

I have a PHP script that is supposed to check for \"valid\" human names, but recently cracked against a name with a space, so we added spaces to our validator.
Rather th

4条回答
  •  天涯浪人
    2020-11-28 16:37

    Don't make any assumptions about how a name may pe spelled. Accept any input (yes, any), and do proper escaping when displaying it, so you don't get XSS vulnerabilities.

    I'd suggest you do this escaping in the model on afterFind(), so you don't forget it somewhere. Keep the original data in a separate field of the model, like ['unescaped_name'], if you need to access the plain data.

提交回复
热议问题