diff --git a/SAX2.c b/SAX2.c index 474ea372..968da080 100644 --- a/SAX2.c +++ b/SAX2.c @@ -2503,10 +2503,7 @@ xmlSAX2Reference(void *ctx, const xmlChar *name) xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2Reference(%s)\n", name); #endif - if (name[0] == '#') - ret = xmlNewCharRef(ctxt->myDoc, name); - else - ret = xmlNewReference(ctxt->myDoc, name); + ret = xmlNewReference(ctxt->myDoc, name); #ifdef DEBUG_SAX_TREE xmlGenericError(xmlGenericErrorContext, "add xmlSAX2Reference %s to %s \n", name, ctxt->node->name); diff --git a/parser.c b/parser.c index ad8675d2..942029a6 100644 --- a/parser.c +++ b/parser.c @@ -6867,42 +6867,19 @@ xmlParseReference(xmlParserCtxtPtr ctxt) { if (NXT(1) == '#') { int i = 0; xmlChar out[16]; - int hex = NXT(2); int value = xmlParseCharRef(ctxt); if (value == 0) return; - if (ctxt->charset != XML_CHAR_ENCODING_UTF8) { - /* - * So we are using non-UTF-8 buffers - * Check that the char fit on 8bits, if not - * generate a CharRef. - */ - if (value <= 0xFF) { - out[0] = value; - out[1] = 0; - if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL) && - (!ctxt->disableSAX)) - ctxt->sax->characters(ctxt->userData, out, 1); - } else { - if ((hex == 'x') || (hex == 'X')) - snprintf((char *)out, sizeof(out), "#x%X", value); - else - snprintf((char *)out, sizeof(out), "#%d", value); - if ((ctxt->sax != NULL) && (ctxt->sax->reference != NULL) && - (!ctxt->disableSAX)) - ctxt->sax->reference(ctxt->userData, out); - } - } else { - /* - * Just encode the value in UTF-8 - */ - COPY_BUF(0 ,out, i, value); - out[i] = 0; - if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL) && - (!ctxt->disableSAX)) - ctxt->sax->characters(ctxt->userData, out, i); - } + + /* + * Just encode the value in UTF-8 + */ + COPY_BUF(0, out, i, value); + out[i] = 0; + if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL) && + (!ctxt->disableSAX)) + ctxt->sax->characters(ctxt->userData, out, i); return; }