symfony - Validation (vs) Sanitization in Symfony2+Twig? -


i need users enter uri of personal website in profile other users can see , click on it. worried lead xss attacks if output not sanitized properly.

like in simplistic schema below:


enter image description here


i using full stack symfony2 framework, doctrine orm , twig template engine. know symfony provides amazing validation tools, , twig provides automatic output escaping (which not necessary in particular case) some filters output sanitizing.

i've read following how symfony2 , twig handle sanitization:

doctrine comes sanitization database (sql) injections. apart this, there no recommended / provided input sanitization @ controller level in symfony2. however, using twig in view, output sanitization available.

as example, in cakephp however:

data sanitization implemented utility can accessed anywhere (controller, component, model .. view). follows sanitize-all-input approach fixed set of predefined sanitization filters. sanitizing specific inputs dedicated rules possible, seems not encouraged.the existing rules concentrate on sql , html injections , filtering out general suspicious unicode characters.

1 how symfony2 + twig users handle input sanitization? discard input sanitization totally , example rely on validation only? or write own utility function filter user inputs? or maybe use library owasp-esapi-php?

2 how symfony2 + twig users handle output sanitization? rely on filters provided twig engine only? example, there tools 1 can use sanitize user-entered uri, something similar this?

3 in situarion, how handle database storage , display of user-entered uri in example above, care input sanitization @ all? or use output sanitization , store uri is?

  1. you should not worry @ input sanitization, doctrine immune sql injection

  2. by default, output escaped. if $text has script tags, escaped; visible text not executed browser. , if want have http://example.com clickable, there jquery plugins can you.

  3. i put validation, there

    new symfony\component\validator\constraints\url() ; 

available you


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -