mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Encoding multibyte characters in custom X-Status HTTP headers used in CMS (headers don't allow multibyte data)
This commit is contained in:
parent
45ae2465e8
commit
d42ea5a9d6
@ -726,7 +726,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
$this->extend('onAfterSave', $record);
|
||||
$this->setCurrentPageID($record->ID);
|
||||
|
||||
$this->response->addHeader('X-Status', _t('LeftAndMain.SAVEDUP'));
|
||||
$this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.SAVEDUP')));
|
||||
return $this->getResponseNegotiator()->respond($this->request);
|
||||
}
|
||||
|
||||
@ -739,7 +739,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
|
||||
$record->delete();
|
||||
|
||||
$this->response->addHeader('X-Status', _t('LeftAndMain.SAVEDUP'));
|
||||
$this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.SAVEDUP')));
|
||||
return $this->getResponseNegotiator()->respond(
|
||||
$this->request,
|
||||
array('currentform' => array($this, 'EmptyForm'))
|
||||
@ -809,7 +809,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
}
|
||||
}
|
||||
|
||||
$this->response->addHeader('X-Status', _t('LeftAndMain.REORGANISATIONSUCCESSFUL', 'Reorganised the site tree successfully.'));
|
||||
$this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.REORGANISATIONSUCCESSFUL', 'Reorganised the site tree successfully.')));
|
||||
}
|
||||
|
||||
// Update sorting
|
||||
@ -830,7 +830,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
}
|
||||
}
|
||||
|
||||
$this->response->addHeader('X-Status', _t('LeftAndMain.REORGANISATIONSUCCESSFUL', 'Reorganised the site tree successfully.'));
|
||||
$this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.REORGANISATIONSUCCESSFUL', 'Reorganised the site tree successfully.')));
|
||||
}
|
||||
|
||||
return Convert::raw2json($statusUpdates);
|
||||
|
@ -246,9 +246,9 @@
|
||||
// Reset action
|
||||
self.find(':input[name=Action]').val('').change();
|
||||
|
||||
// status message
|
||||
// status message (decode into UTF-8, HTTP headers don't allow multibyte)
|
||||
var msg = xmlhttp.getResponseHeader('X-Status');
|
||||
if(msg) statusMessage(msg, (status == 'success') ? 'good' : 'bad');
|
||||
if(msg) statusMessage(decodeURIComponent(msg), (status == 'success') ? 'good' : 'bad');
|
||||
},
|
||||
success: function(data, status) {
|
||||
var id, node;
|
||||
|
@ -147,9 +147,6 @@
|
||||
|
||||
this.trigger('reloadeditform', {form: form, origData: origData, xmlhttp: xmlhttp});
|
||||
}
|
||||
|
||||
// set status message based on response
|
||||
var _statusMessage = (xmlhttp.getResponseHeader('X-Status')) ? xmlhttp.getResponseHeader('X-Status') : xmlhttp.statusText;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -55,7 +55,8 @@ jQuery.noConflict();
|
||||
|
||||
// Show message (but ignore aborted requests)
|
||||
if(xhr.status !== 0 && msg && $.inArray(msg, ignoredMessages)) {
|
||||
statusMessage(msg, msgType);
|
||||
// Decode into UTF-8, HTTP headers don't allow multibyte
|
||||
statusMessage(decodeURIComponent(msg), msgType);
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user