Skip to content
Snippets Groups Projects
Commit 508e08c1 authored by Jared Hancock's avatar Jared Hancock
Browse files

Properly transcode message body in API requests

parent d340ee15
Branches
Tags
No related merge requests found
......@@ -328,12 +328,19 @@ class ApiXmlDataParser extends XmlDataParser {
$value = array(
"body" => $value,
"type" => "text/plain",
# TODO: Get encoding from root <xml> node
# Use encoding from root <xml> node
);
} else {
$value["body"] = $value[":text"];
unset($value[":text"]);
}
if (isset($value['encoding']))
$value['body'] = Format::utf8encode($value['body'], $value['encoding']);
if (!isset($value['type']) || $value['type'] != 'text/html')
$value = sprintf('<div style="white-space:pre-wrap">%s</div>',
Format::htmlchars($value['body']));
else
$value = $value['body'];
} else if ($key == "attachments") {
if(!isset($value['file'][':text']))
$value = $value['file'];
......@@ -351,10 +358,6 @@ class ApiXmlDataParser extends XmlDataParser {
}
unset($value);
if(isset($current['message']) && $current['message'])
$current['message'] = sprintf('<div style="white-space:pre-wrap">%s</div>',
Format::htmlchars($current['message']));
return $current;
}
}
......
......@@ -735,7 +735,7 @@ class SelectionField extends FormField {
'value'=>$value,
'list_id'=>$this->getListId()));
}
return ($item) ? $item : $id;
return ($item) ? $item : $value;
}
function to_database($item) {
......
......@@ -166,8 +166,8 @@ class FormField {
*/
function getClean() {
if (!isset($this->_clean)) {
$value = $this->getWidget()->value;
$this->_clean = $this->parse($value);
$this->_clean = (isset($this->value))
? $this->value : $this->parse($this->getWidget()->value);
$this->validateEntry($this->_clean);
}
return $this->_clean;
......
......@@ -19,7 +19,7 @@
class XmlDataParser {
function XmlDataParser() {
$this->parser = xml_parser_create();
$this->parser = xml_parser_create('utf-8');
xml_set_object($this->parser, $this);
xml_set_element_handler($this->parser, "startElement", "endElement");
xml_set_character_data_handler($this->parser, "content");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment