diff --git a/include/class.api.php b/include/class.api.php index 67f2855274dac367ccc9158b2a480d08fa6596b5..6dec23efbc71969df796ecb8d9fc206f090b4129 100644 --- a/include/class.api.php +++ b/include/class.api.php @@ -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; } } diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index e803235c80fe85b4942d89e8380cc9c1c4929a39..79a092cbbc98dcb7c26e8771a419c7e06be0207e 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -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) { diff --git a/include/class.forms.php b/include/class.forms.php index b51629bc5c69fcca17a905e5916b58dd349e4f6a..6385f4190ca6d16f7b2f8834f419d4a471a66152 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -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; diff --git a/include/class.xml.php b/include/class.xml.php index 56baf4fbccaf65985921e081afd8e5f475c95c07..ff011eaa4f4a714e2a1f50064dfcb6f5d21cc3d0 100644 --- a/include/class.xml.php +++ b/include/class.xml.php @@ -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");