creativedotdesign / tofino

WordPress boilerplate theme on a modern stack. NPM and Composer.
Other
29 stars 6 forks source link

Ajax Form Construct Data Sanitize #243

Closed danimalweb closed 7 years ago

danimalweb commented 7 years ago

Related to PR #229.

The implemented fix does not account for inputs with array based names. e.g.

<input type="checkbox" name="thing[]" value="123">
<input type="checkbox" name="thing[]" value="456">

I can't get the values from thing or thing[] as they are removed by the new sanitisation code.

This is what I use in another project and it allows the arrays through. Any thoughts?

$this->post = $_POST;

    $args = [
      'data' => [
        'filter' => FILTER_SANITIZE_STRING,
        'flags'  => FILTER_FLAG_NO_ENCODE_QUOTES
      ]
    ];

    $this->form_data = filter_var_array($this->post, $args);

    parse_str($this->post['data'], $this->form_data);

cc: @mattpill @mrchimp

mrchimp commented 7 years ago

Hmm that might work. Need to test...

https://media.giphy.com/media/13d94kJxnSZohG/giphy.gif