0

I have a view with a search filter. I am using Acunetix scanner to scan for vulnerabilities, which reports me an issue about the search filter. How do I alter it to use check_plain(filter_xss($string)) or filter_xss(check_plain($string)) in view exposed forms (a block, in my case)?

  • I find it odd and hard to believe that views doesn't do this already... Perhaps somewhere behind the scenes, they are already doing this? – No Sssweat Apr 19 '16 at 7:42
1

You can write a form alter in your custom module. ie :

function mymodule_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == 'views_exposed_form') {
        $view = $form_state['view'];
        if ($view->name == 'my_view_machine_name' && $view->current_display == 'display_name') {
            // alter your exposed form here
            $form['yourdata_item'] = check_plain(filter_xss($string));
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.