Permalink
Browse files

CMS Titles does not support UTF-8

Title in CMS is set using header X-Title. But UTF-8 characters can't be used in HTTP headers. So the title should be encoded just before sending X-Title header and decoded before setting HTML document title (fixes #7942).
  • Loading branch information...
1 parent 0d37cd3 commit 77212c064768b03634c7f9e583fca90b9b9651d1 @uniun uniun committed with chillu Dec 17, 2012
Showing with 3 additions and 2 deletions.
  1. +1 −1 admin/code/LeftAndMain.php
  2. +1 −1 admin/javascript/LeftAndMain.js
  3. +1 −0 docs/en/reference/cms-architecture.md
View
2 admin/code/LeftAndMain.php
@@ -357,7 +357,7 @@ public function handleRequest(SS_HTTPRequest $request, DataModel $model = null)
$response = parent::handleRequest($request, $model);
$title = $this->Title();
if(!$response->getHeader('X-Controller')) $response->addHeader('X-Controller', $this->class);
- if(!$response->getHeader('X-Title')) $response->addHeader('X-Title', $title);
+ if(!$response->getHeader('X-Title')) $response->addHeader('X-Title', urlencode($title));
return $response;
}
View
2 admin/javascript/LeftAndMain.js
@@ -462,7 +462,7 @@ jQuery.noConflict();
// Update title
var title = xhr.getResponseHeader('X-Title');
- if(title) document.title = title;
+ if(title) document.title = decodeURIComponent(title.replace(/\+/g, ' '));
var newFragments = {}, newContentEls;
// If content type is text/json (ignoring charset and other parameters)
View
1 docs/en/reference/cms-architecture.md
@@ -311,6 +311,7 @@ without affecting the response body.
Built-in headers are:
+ * `X-Title`: Set window title (requires URL encoding)
* `X-Controller`: PHP class name matching a menu entry, which is marked active
* `X-ControllerURL`: Alternative URL to record in the HTML5 browser history
* `X-Status`: Extended status information, used for an information popover.

0 comments on commit 77212c0

Please sign in to comment.