Revision: 14814
Updated Code
at June 12, 2009 17:00 by caioariede
Updated Code
/** * Fetch an item from a global array. * * @param array array to search * @param string key to find * @param mixed default value * @param boolean XSS clean the value * @return mixed */ protected function search_array($array, $key, $default = NULL, $xss_clean = FALSE) { if ($key === array()) return $array; //$key = 'option[min][max][x]'; // patch: start if (preg_match_all('!(?:\[([^]]+)\])!', $key, $subkeys)) { list(, $subkeys) = $subkeys; array_unshift($subkeys, substr($key, 0, strpos($key, '['))); foreach ($subkeys as $key) { if ( ! isset($array[$key])) return $default; $array = $array[$key]; } return $array; } // end if ( ! isset($array[$key])) return $default; // Get the value $value = $array[$key]; if ($this->use_xss_clean === FALSE AND $xss_clean === TRUE) { // XSS clean the value $value = $this->xss_clean($value); } return $value; }
Revision: 14813
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 12, 2009 16:54 by caioariede
Initial Code
/** * Fetch an item from a global array. * * @param array array to search * @param string key to find * @param mixed default value * @param boolean XSS clean the value * @return mixed */ protected function search_array($array, $key, $default = NULL, $xss_clean = FALSE) { if ($key === array()) return $array; // patch: start if (preg_match('!(^\w+)(?:\[([^]]+)\])!', $key, $subkeys)) { array_shift($subkeys); foreach ($subkeys as $key) { if ( ! isset($array[$key])) return $default; $array = $array[$key]; } return $array; } // end if ( ! isset($array[$key])) return $default; // Get the value $value = $array[$key]; if ($this->use_xss_clean === FALSE AND $xss_clean === TRUE) { // XSS clean the value $value = $this->xss_clean($value); } return $value; }
Initial URL
Initial Description
Initial Title
Kohana Patch: Input library problem with [ and ]
Initial Tags
Initial Language
PHP