简体   繁体   中英

Convert special characters to HTML entities, Laravel

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?

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM