Ad

Convert Special Characters To HTML Entities, Laravel

- 1 answer

I am trying to convert special characters for safe output in my view using Laravel. I know blade does this for you - but all my data is being displayed via JavaScript Ajax requests. My original function for accomplishing this doesn't seem to work (used with CodeIgniter):

       //sanitize tasks for safe output
        function sanitize_object_h( $array ) {
            $array_modified = $array;

            foreach( $array_modified as $object ) {
                foreach( $object as &$item ) {
                    $item = htmlentities( $item, ENT_QUOTES );
                }
                //end foreach
            }
            //end foreach
            return $array_modified;

        }
        //end sanitize_object_h

Does Laravel provide a convenient way of converting large numbers of database records for safe output?

Ad

Answer

We have not provided an XSS filter, as it is more at the users discretion. There is, however, a great article with a ready-to-go XSS filter function located at this link.

I hope this helps!

Ad
source: stackoverflow.com
Ad