Skip to content

Commit

Permalink
BUGFIX Encoding multibyte characters in custom X-Status HTTP headers …
Browse files Browse the repository at this point in the history
…used in CMS (headers don't allow multibyte data)
  • Loading branch information
chillu committed May 14, 2012
1 parent c3735ec commit 73e5c34
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions code/controllers/AssetAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}

Expand Down
22 changes: 11 additions & 11 deletions code/controllers/CMSMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand All @@ -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"
Expand All @@ -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);
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/CMSSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion code/model/ErrorPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 73e5c34

Please sign in to comment.