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 45ae246 commit d42ea5a9d6fb63677e3797f06078880f7f9c81cd @chillu chillu committed May 14, 2012
@@ -726,7 +726,7 @@ public function save($data, $form) {
$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 @@ public function delete($data, $form) {
$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 @@ public function savetreenode($request) {
}
}
- $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 @@ public function savetreenode($request) {
}
}
- $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);
}
});

0 comments on commit d42ea5a

Please sign in to comment.