Skip to content

Commit

Permalink
Updated formatting and styleguide, thanks narfbg;
Browse files Browse the repository at this point in the history
  • Loading branch information
chernjie committed Dec 6, 2012
1 parent af3bd3e commit 0bf9cfa
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions system/core/URI.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,23 +219,29 @@ protected function _parse_request_uri()
}

// Do some final cleaning of the URI and return it
return $this->_remove_relative_directory_str($uri);
return $this->_remove_relative_directory($uri);
}

// --------------------------------------------------------------------

/**
* Remove relative directory (../) and multi slashes (///)
* @param string $url
* @return string
*
* Do some final cleaning of the URI and return it, currently only used in self::_parse_request_uri()
*
* @param string $url
* @return string
*/
private function _remove_relative_directory_str($url)
protected function _remove_relative_directory($uri)
{
$uris = array();
$tok = strtok($url, '/');
while ($tok !== false)
$tok = strtok($uri, '/');
while ($tok !== FALSE)
{
($tok != '..' && ! empty($tok) || $tok === '0') && $uris[] = $tok;
if (( ! empty($tok) OR $tok === '0') && $tok !== '..')
{
$uris[] = $tok;
}
$tok = strtok('/');
}
return implode('/', $uris);
Expand Down

0 comments on commit 0bf9cfa

Please sign in to comment.