Changeset 405

Show
Ignore:
Timestamp:
03/19/07 23:59:40 (1 year ago)
Author:
mikey
Message:

strip slashes from input values

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/ipo/request/stubWebRequest.php

    r402 r405  
    2525    protected function doConstuct() 
    2626    { 
    27         $this->unsecureParams = array_merge($_GET, $_POST); 
     27        $this->unsecureParams = array_merge(array_map(array($this, 'stripslashes'), $_GET), array_map(array($this, 'stripslashes'), $_POST)); 
    2828        foreach ($_SERVER as $key => $value) { 
    2929            if (substr($key, 0, 5) == 'HTTP_' || substr($key, 0, 7) == 'REMOTE_') { 
     
    3232        } 
    3333        $this->unsecureCookies = $_COOKIE; 
     34    } 
     35     
     36    /** 
     37     * strips slashes from request variables, even if request variable is an array 
     38     * (wrapper around native stripslashes()) 
     39     * 
     40     * @param   string|array  $value  request variable value to apply stripslashes on 
     41     * @return  string|array  stripslashed' value 
     42     */ 
     43    private function stripSlashes($value) 
     44    { 
     45        if (is_array($value) == FALSE) { 
     46            $value = stripslashes($value); 
     47        } else { 
     48            $tmp = array(); 
     49            foreach ($value as $id => $content) { 
     50                $tmp[$id] = $this->stripslashes($content); 
     51            } 
     52             
     53            $value = $tmp; 
     54        } 
     55         
     56        return $value; 
    3457    } 
    3558