Skip to content
Browse files

switch from using the /e modifier to preg_replace_callback()

refs #4591
  • Loading branch information...
1 parent 3c7fc8c commit 996b8742f706ecf1b26ea2c8d99e646570d8bf90 Lorenzo Pisani committed
Showing with 13 additions and 1 deletion.
  1. +13 −1 classes/kohana/url.php
View
14 classes/kohana/url.php
@@ -112,7 +112,7 @@ public static function site($uri = '', $protocol = NULL, $index = TRUE)
if ( ! UTF8::is_ascii($path))
{
// Encode all non-ASCII characters, as per RFC 1738
- $path = preg_replace('~([^/]+)~e', 'rawurlencode("$1")', $path);
+ $path = preg_replace_callback('~([^/]+)~', 'URL::_rawurlencode_callback', $path);
}
// Concat the URL
@@ -120,6 +120,18 @@ public static function site($uri = '', $protocol = NULL, $index = TRUE)
}
/**
+ * Callback used for encoding all non-ASCII characters, as per RFC 1738
+ * Used by URL::site()
+ *
+ * @param array $matches Array of matches from preg_replace_callback()
+ * @return string Encoded string
+ */
+ protected static function _rawurlencode_callback($matches)
+ {
+ return rawurlencode($matches[0]);
+ }
+
+ /**
* Merges the current GET parameters with an array of new or overloaded
* parameters and returns the resulting query string.
*

0 comments on commit 996b874

Please sign in to comment.
Something went wrong with that request. Please try again.