Permalink
Browse files

ENHANCEMENT Url encoding URLSegments before matching them against dat…

…abase records in ModelAsController, to match behaviour of SiteTree with URLSegmentFilter::$default_allow_multibyte=true. Not an API change because all encodable characters have been removed by the default URLSegmentFilter already (see http://www.w3.org/International/articles/idn-and-iri/#iriproblem)
  • Loading branch information...
chillu committed May 8, 2012
1 parent 63536af commit 77e52d6344bca19eeebff703d131602f31a9c342
Showing with 4 additions and 4 deletions.
  1. +1 −1 code/controllers/ContentController.php
  2. +3 −3 code/controllers/ModelAsController.php
@@ -146,7 +146,7 @@ public function handleRequest(SS_HTTPRequest $request, DataModel $model = null)
if(class_exists('Translatable')) Translatable::disable_locale_filter();
// look for a page with this URLSegment
$child = $this->model->SiteTree->where(sprintf (
- "\"ParentID\" = %s AND \"URLSegment\" = '%s'", $this->ID, Convert::raw2sql($action)
+ "\"ParentID\" = %s AND \"URLSegment\" = '%s'", $this->ID, Convert::raw2sql(rawurlencode($action))
))->First();
if(class_exists('Translatable')) Translatable::enable_locale_filter();
@@ -87,14 +87,14 @@ public function getNestedController() {
if(!$URLSegment = $request->param('URLSegment')) {
throw new Exception('ModelAsController->getNestedController(): was not passed a URLSegment value.');
}
-
+
// Find page by link, regardless of current locale settings
if(class_exists('Translatable')) Translatable::disable_locale_filter();
$sitetree = DataObject::get_one(
'SiteTree',
sprintf(
'"URLSegment" = \'%s\' %s',
- Convert::raw2sql($URLSegment),
+ Convert::raw2sql(rawurlencode($URLSegment)),
(SiteTree::nested_urls() ? 'AND "ParentID" = 0' : null)
)
);
@@ -149,7 +149,7 @@ public function getNestedController() {
* @return SiteTree
*/
static function find_old_page($URLSegment,$parentID = 0, $ignoreNestedURLs = false) {
- $URLSegment = Convert::raw2sql($URLSegment);
+ $URLSegment = Convert::raw2sql(rawurlencode($URLSegment));
$useParentIDFilter = SiteTree::nested_urls() && $parentID;

0 comments on commit 77e52d6

Please sign in to comment.