Skip to content

Commit

Permalink
Fixed url decoding and encoding issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Turcotte authored and Jeff Turcotte committed Aug 12, 2010
1 parent 82381c9 commit e5ab6f9
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions Moor.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @license MIT (see LICENSE or bottom of this file)
* @package Moor
* @link http://github.com/jeffturcotte/moor
* @version 1.0.0b6
* @version 1.0.0b7
*/
class Moor {
/**
Expand Down Expand Up @@ -292,7 +292,11 @@ public static function linkTo($key)
$excluded_params = array_intersect_key($params, $cache->excluded_param_names);

foreach($included_params as $name => $value) {
$url = str_replace(':'.$name, $value, $url);
$url = str_replace(':'.$name, urlencode($value), $url);
}

foreach($excluded_params as $name => $value) {
$excluded_params[$name] = urlencode($value);
}

if (!empty($excluded_params)) {
Expand Down Expand Up @@ -426,11 +430,11 @@ public static function pathTo($callback, $directory_separator=NULL)
}

/**
* Find the params to a particular callback. Will return an array of valid param
* names from all URLs associated with a callback.
* Find the params to a particular callback. Will return an array of arrays.
* one per router with valid param of the route's URL.
*
* @param string $callback The callback to search for
* @return array The params from all URLs associated with a callback
* @return array The params
*/
public static function paramsTo($callback)
{
Expand Down Expand Up @@ -516,7 +520,7 @@ public static function route($url_string, $callback_string, $function=NULL)
public static function run()
{
self::$running = TRUE;
self::$request_path = preg_replace('#\?.*$#', '', $_SERVER['REQUEST_URI']);
self::$request_path = urldecode(preg_replace('#\?.*$#', '', $_SERVER['REQUEST_URI']));

$old_GET = $_GET;
$_GET = array();
Expand Down Expand Up @@ -703,7 +707,7 @@ private static function dispatchRoute($route)

foreach($matches as $name => $param) {
if (is_string($name)) {
$_GET[$name] = $param;
$_GET[$name] = urldecode($param);
}
}

Expand Down

0 comments on commit e5ab6f9

Please sign in to comment.