diff -urN wbxml2-0.9.0.orig/src/wbxml_encoder.c wbxml2-0.9.0/src/wbxml_encoder.c --- wbxml2-0.9.0.orig/src/wbxml_encoder.c 2005-11-30 22:48:18.000000000 +0100 +++ wbxml2-0.9.0/src/wbxml_encoder.c 2005-11-30 22:47:55.000000000 +0100 @@ -98,6 +98,7 @@ WBXMLTree *tree; /**< WBXML Tree to Encode */ WBXMLBuffer *output; /**< The output (wbxml or xml) we are producing */ const WBXMLTagEntry *current_tag; /**< Current Tag (See The Warning For This Field !) */ + const WBXMLTreeNode *current_text_parent; /**< Parent of the current Node (Used for DRM REL) */ const WBXMLAttrEntry *current_attr; /**< Current Attribute */ WB_UTINY tagCodePage; /**< Current Tag Code Page */ WB_UTINY attrCodePage; /**< Current Attribute Code Page */ @@ -335,6 +336,7 @@ encoder->output = NULL; encoder->current_tag = NULL; + encoder->current_text_parent = NULL; encoder->current_attr = NULL; encoder->tagCodePage = 0; @@ -831,6 +833,8 @@ */ static WBXMLError parse_text(WBXMLEncoder *encoder, WBXMLTreeNode *node) { + WBXMLError ret; + /* Do not modify text inside a CDATA section */ if (!encoder->in_cdata) { /* If Canonical Form: "Ignorable white space is considered significant and is treated equivalently to data" */ @@ -877,7 +881,10 @@ } else { /* Encode text */ - return wbxml_encode_value_element_buffer(encoder, wbxml_buffer_get_cstr(node->content), WBXML_VALUE_ELEMENT_CTX_CONTENT); + encoder->current_text_parent = node->parent; + ret = wbxml_encode_value_element_buffer(encoder, wbxml_buffer_get_cstr(node->content), WBXML_VALUE_ELEMENT_CTX_CONTENT); + encoder->current_text_parent = NULL; + return ret; } case WBXML_ENCODER_OUTPUT_XML: return xml_encode_text(encoder, node->content); @@ -2650,11 +2657,19 @@ { WB_UTINY *data = NULL; WB_LONG data_len = 0; + WBXMLTagEntry *current_tag = NULL; - if (encoder->current_tag != NULL) + if ((encoder->current_text_parent != NULL) && + (encoder->current_text_parent->name != NULL) && + (encoder->current_text_parent->name->type == WBXML_VALUE_TOKEN)) + { + current_tag = encoder->current_text_parent->name->u.token; + } + + if (current_tag != NULL) { - if ((encoder->current_tag->wbxmlCodePage == 0x00) && - (encoder->current_tag->wbxmlToken == 0x0C)) + if ((current_tag->wbxmlCodePage == 0x00) && + (current_tag->wbxmlToken == 0x0C)) { /* content: "Encoded in binary format, i.e., no base64 encoding" */