--- parser3/src/classes/xdoc.C 2017/02/07 22:00:30 1.192 +++ parser3/src/classes/xdoc.C 2019/11/28 10:49:23 1.196 @@ -28,7 +28,7 @@ #include "xnode.h" #include "pa_charsets.h" -volatile const char * IDENT_XDOC_C="$Id: xdoc.C,v 1.192 2017/02/07 22:00:30 moko Exp $"; +volatile const char * IDENT_XDOC_C="$Id: xdoc.C,v 1.196 2019/11/28 10:49:23 moko Exp $"; // defines @@ -168,9 +168,8 @@ struct IdsIteratorInfo { xmlNode *element; }; -/* Hash Scanner function for pa_getElementById */ -extern "C" void // switching to calling convetion of libxml -idsHashScanner (void *payload, void *data, xmlChar *name) { +/* switching to calling convetion of libxml */ +extern "C" void idsHashScanner (void *payload, void *data, const xmlChar *name) { IdsIteratorInfo *priv = (IdsIteratorInfo *)data; if (priv->element == NULL && xmlStrEqual (name, priv->elementId)) @@ -181,11 +180,10 @@ idsHashScanner (void *payload, void *dat } } -static xmlNode* -pa_getElementById(xmlDoc& xmldoc, xmlChar* elementId) { +static xmlNode* pa_getElementById(xmlDoc& xmldoc, xmlChar* elementId) { xmlHashTable *ids = (xmlHashTable *)xmldoc.ids; IdsIteratorInfo iter={elementId, NULL}; - xmlHashScan(ids, idsHashScanner, &iter); + xmlHashScan(ids, (xmlHashScanner)idsHashScanner, &iter); return iter.element; } @@ -366,10 +364,7 @@ static void _importNode(Request& r, Meth writeNode(r, vdoc, node); } -/* -GdomeElement *gdome_doc_createElementNS (GdomeDocument *self, GdomeDOMString *namespaceURI, GdomeDOMString *qualifiedName, GdomeException *exc); -GdomeAttr *gdome_doc_createAttributeNS (GdomeDocument *self, GdomeDOMString *namespaceURI, GdomeDOMString *qualifiedName, GdomeException *exc); -*/ +#define XML_PARSE_OPTIONS (XML_PARSE_DTDLOAD | XML_PARSE_NOENT | XML_PARSE_HUGE) static void _create(Request& r, MethodParams& params) { Charset& source_charset=r.charsets.source(); @@ -383,9 +378,8 @@ static void _create(Request& r, MethodPa const String& xml=r.process_to_string(param); String::Body sbody=xml.cstr_to_string_body_untaint(String::L_XML, r.connection(false), &r.charsets); - xmldoc=xmlParseMemory(sbody.cstr(), sbody.length()); + xmldoc=xmlReadMemory(sbody.cstr(), sbody.length(), NULL, NULL, XML_PARSE_OPTIONS); - //printf("document=0x%p\n", document); if(!xmldoc || xmlHaveGenericErrors()) throw XmlException(0, r); @@ -396,19 +390,6 @@ static void _create(Request& r, MethodPa if(xmlValidateNCName(localName, 0) != 0) throw XmlException(0, XML_INVALID_LOCAL_NAME, localName); -#if 0 - GdomeDocumentType *documentType=gdome_di_createDocumentType ( - docimpl, - r.transcode(qualifiedName), - 0/*publicId*/, - 0/*systemId*/, - &exc); - if(!documentType || exc || xmlHaveGenericErrors()) - throw Exception( - method_name, - exc); - /// +xalan createXMLDecl ? -#endif xmldoc=xmlNewDoc(0); if(!xmldoc || xmlHaveGenericErrors()) throw XmlException(0, r); @@ -421,7 +402,7 @@ static void _create(Request& r, MethodPa // must be last action in if, see after if} } else { VFile* vfile=param.as_vfile(String::L_AS_IS); - xmldoc=xmlParseMemory(vfile->value_ptr(), vfile->value_size()); + xmldoc=xmlReadMemory(vfile->value_ptr(), vfile->value_size(), NULL, NULL, XML_PARSE_OPTIONS); if(!xmldoc || xmlHaveGenericErrors()) throw XmlException(0, r); } @@ -458,7 +439,7 @@ static void _load(Request& r, MethodPara uri_cstr=uri->taint_cstr(String::L_AS_IS); // leave as-is for xmlParseFile to handle /// @todo!! add SAFE MODE!! - xmlDoc* xmldoc=xmlParseFile(uri_cstr); + xmlDoc* xmldoc=xmlReadFile(uri_cstr, NULL, XML_PARSE_OPTIONS); if(!xmldoc || xmlHaveGenericErrors()) throw XmlException(uri, r); @@ -675,7 +656,7 @@ static void _transform(Request& r, Metho const xmlChar** transform_params=0; if(params.count()>1) if(HashStringValue* hash=params.as_hash(1, "transform options")) { - transform_params=new const xmlChar*[hash->count()*2+1]; + transform_params=new(PointerGC) const xmlChar*[hash->count()*2+1]; Add_xslt_param_info info={ &r, &transform_strings,