Permalink
Browse files

BUGFIX Encoding multibyte characters in custom X-Status HTTP headers …

…used in CMS (headers don't allow multibyte data)
  • Loading branch information...
1 parent c3735ec commit 73e5c34896f1d2746185840864fc0f411dfad245 @chillu chillu committed May 14, 2012
@@ -478,7 +478,7 @@ public function SiteTreeAsUL() {
*/
public function doSync() {
$message = Filesystem::sync();
- $this->response->addHeader('X-Status', $message);
+ $this->response->addHeader('X-Status', rawurlencode($message));
return;
}
@@ -512,7 +512,7 @@ public function deleteunusedthumbnails($request) {
'{count} unused thumbnails have been deleted',
array('count' => $count)
);
- $this->response->addHeader('X-Status', $message);
+ $this->response->addHeader('X-Status', rawurlencode($message));
return;
}
@@ -796,15 +796,15 @@ public function save($data, $form) {
$this->response->addHeader(
'X-Status',
- _t(
+ rawurlencode(_t(
'LeftAndMain.STATUSPUBLISHEDSUCCESS',
"Published '{title}' successfully",
'Status message after publishing a page, showing the page title',
array('title' => $record->Title)
- )
+ ))
);
} else {
- $this->response->addHeader('X-Status', _t('LeftAndMain.SAVEDUP'));
+ $this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.SAVEDUP')));
}
return $this->getResponseNegotiator()->respond($this->request);
@@ -891,7 +891,7 @@ public function deletefromlive($data, $form) {
$this->response->addHeader(
'X-Status',
- sprintf(_t('CMSMain.REMOVED', 'Deleted \'%s\'%s from live site'), $recordTitle, $descRemoved)
+ rawurlencode(sprintf(_t('CMSMain.REMOVED', 'Deleted \'%s\'%s from live site'), $recordTitle, $descRemoved))
);
// Even if the record has been deleted from stage and live, it can be viewed in "archive mode"
@@ -936,12 +936,12 @@ public function revert($data, $form) {
$this->response->addHeader(
'X-Status',
- _t(
+ rawurlencode(_t(
'CMSMain.RESTORED',
"Restored '{title}' successfully",
'Param %s is a title',
array('title' => $record->Title)
- )
+ ))
);
return $this->getResponseNegotiator()->respond($this->request);
@@ -966,7 +966,7 @@ public function delete($data, $form) {
$this->response->addHeader(
'X-Status',
- sprintf(_t('CMSMain.REMOVEDPAGEFROMDRAFT',"Removed '%s' from the draft site"), $record->Title)
+ rawurlencode(sprintf(_t('CMSMain.REMOVEDPAGEFROMDRAFT',"Removed '%s' from the draft site"), $record->Title))
);
// Even if the record has been deleted from stage and live, it can be viewed in "archive mode"
@@ -990,7 +990,7 @@ function unpublish($data, $form) {
$this->response->addHeader(
'X-Status',
- _t('CMSMain.REMOVEDPAGE',"Removed '{title}' from the published site", array('title' => $record->Title))
+ rawurlencode(_t('CMSMain.REMOVEDPAGE',"Removed '{title}' from the published site", array('title' => $record->Title)))
);
return $this->getResponseNegotiator()->respond($this->request);
@@ -1038,7 +1038,7 @@ function doRollback($data, $form) {
);
}
- $this->response->addHeader('X-Status', $message);
+ $this->response->addHeader('X-Status', rawurlencode($message));
// Can be used in different contexts: In normal page edit view, in which case the redirect won't have any effect.
// Or in history view, in which case a revert causes the CMS to re-load the edit view.
@@ -1187,11 +1187,11 @@ function restore($data, $form) {
$this->response->addHeader(
'X-Status',
- _t(
+ rawurlencode(_t(
'CMSMain.RESTORED',
"Restored '{title}' successfully",
array('title' => $restoredPage->TreeTitle)
- )
+ ))
);
return $this->getResponseNegotiator()->respond($this->request);
@@ -45,7 +45,7 @@ function save_siteconfig($data, $form) {
$form->saveInto($siteConfig);
$siteConfig->write();
- $this->response->addHeader('X-Status', _t('LeftAndMain.SAVEDUP'));
+ $this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.SAVEDUP')));
return $form->forTemplate();
}
View
@@ -209,7 +209,7 @@ function doPublish() {
"Error opening file \"{filename}\" for writing. Please check file permissions.",
array('filename' => $errorFile)
);
- $this->response->addHeader('X-Status', $fileErrorText);
+ $this->response->addHeader('X-Status', rawurlencode($fileErrorText));
return $this->httpError(405);
}
}

0 comments on commit 73e5c34

Please sign in to comment.