Welcome Guest, Not a member yet? Register   Sign In
Form validation: Is "htmlspecialchars" run no matter what?
#1

[eluser]davidbehler[/eluser]
Ok, I have this setup:

form_validation.php in config folder:
Code:
$config = array
   (
      'post' => array
                  (
                     array
                        (
                           'field' => 'post_content',
                           'label' => 'Content',
                           'rules' => 'trim|required|xss_clean'
                        )
                  )
   )

test.php in controller folder:
Code:
function post()
   {
      $this->load->library('form_validation');
      if ($this->form_validation->run('post') == FALSE)
      {
         // show error message
      }
      else
      {
         // do some stuff
      }
      $this->load->view('post');
   }

post.php in view folder:
Code:
echo form_open('test/post');

$data = array(
            'name' => 'post_content',
            'id' => 'post_content',
            'cols' => '100',
            'rows' => '5',
            'value' => set_value('post_content')
);

echo form_textarea($data);


echo form_submit(array('value'=>'submit'));
echo form_close();

So far so easy, but now I got the following problem:
No matter what I enter into textarea, it seems like it's run through "htmlspecialchars", even though I have no such rule defined!

Example:
Entered value: <p>test</p>
"echo set_value('post_content');" BEFORE the validation is run: &lt;p&gt;test&lt;/p&gt;
"echo set_value('post_content');" AFTER the validation is run: ltpgt;testlt;/pgt; (damn board keeps escaping my examples..)

Anyway, the first echo returns the value just like I entered it, the second one returns it as run through "htmlspecialchars" even though there is no such rule for that field!

Any ideas why?
Help appreciated!


Messages In This Thread
Form validation: Is "htmlspecialchars" run no matter what? - by El Forum - 04-04-2009, 09:15 AM



Theme © iAndrew 2016 - Forum software by © MyBB