updated libxml2 to 2.5.10
[TestXSLT.git] / libxml2 / HTMLtree.c
index 94682bb..4efce27 100644 (file)
@@ -383,6 +383,8 @@ htmlNodeDumpFormat(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
  */
 int
 htmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur) {
+    xmlInitParser();
+
     return(htmlNodeDumpFormat(buf, doc, cur, 1));
 }
 
@@ -407,6 +409,8 @@ htmlNodeDumpFileFormat(FILE *out, xmlDocPtr doc,
     xmlCharEncodingHandlerPtr handler = NULL;
     int ret;
 
+    xmlInitParser();
+
     if (encoding != NULL) {
        xmlCharEncoding enc;
 
@@ -467,6 +471,8 @@ htmlDocDumpMemory(xmlDocPtr cur, xmlChar**mem, int *size) {
     xmlCharEncodingHandlerPtr handler = NULL;
     const char *encoding;
 
+    xmlInitParser();
+
     if (cur == NULL) {
 #ifdef DEBUG_TREE
         xmlGenericError(xmlGenericErrorContext,
@@ -605,14 +611,17 @@ htmlAttrDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur,
        value = xmlNodeListGetString(doc, cur->children, 0);
        if (value) {
            xmlOutputBufferWriteString(buf, "=");
-           if ((!xmlStrcasecmp(cur->name, BAD_CAST "href")) ||
-               (!xmlStrcasecmp(cur->name, BAD_CAST "src"))) {
+           if ((cur->ns == NULL) && (cur->parent != NULL) &&
+               (cur->parent->ns == NULL) &&
+               ((!xmlStrcasecmp(cur->name, BAD_CAST "href")) ||
+                (!xmlStrcasecmp(cur->name, BAD_CAST "action")) ||
+                (!xmlStrcasecmp(cur->name, BAD_CAST "src")))) {
                xmlChar *escaped;
                xmlChar *tmp = value;
 
                while (IS_BLANK(*tmp)) tmp++;
 
-               escaped = xmlURIEscapeStr(tmp, BAD_CAST"@/:=?;#%&");
+               escaped = xmlURIEscapeStr(tmp, BAD_CAST"@/:=?;#%&,+");
                if (escaped != NULL) {
                    xmlBufferWriteQuotedString(buf->buffer, escaped);
                    xmlFree(escaped);
@@ -692,6 +701,8 @@ htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
                         xmlNodePtr cur, const char *encoding, int format) {
     const htmlElemDesc * info;
 
+    xmlInitParser();
+
     if (cur == NULL) {
         xmlGenericError(xmlGenericErrorContext,
                "htmlNodeDumpFormatOutput : node == NULL\n");
@@ -797,6 +808,10 @@ htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
            xmlOutputBufferWriteString(buf, ">");
        } else {
            xmlOutputBufferWriteString(buf, "></");
+            if ((cur->ns != NULL) && (cur->ns->prefix != NULL)) {
+                xmlOutputBufferWriteString(buf, (const char *)cur->ns->prefix);
+                xmlOutputBufferWriteString(buf, ":");
+            }
            xmlOutputBufferWriteString(buf, (const char *)cur->name);
            xmlOutputBufferWriteString(buf, ">");
        }
@@ -882,6 +897,8 @@ htmlDocContentDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr cur,
                               const char *encoding, int format) {
     int type;
 
+    xmlInitParser();
+
     /*
      * force to output the stuff as HTML, especially for entities
      */
@@ -933,6 +950,8 @@ htmlDocDump(FILE *f, xmlDocPtr cur) {
     const char *encoding;
     int ret;
 
+    xmlInitParser();
+
     if (cur == NULL) {
 #ifdef DEBUG_TREE
         xmlGenericError(xmlGenericErrorContext,
@@ -993,6 +1012,8 @@ htmlSaveFile(const char *filename, xmlDocPtr cur) {
     const char *encoding;
     int ret;
 
+    xmlInitParser();
+
     encoding = (const char *) htmlGetMetaEncoding(cur);
 
     if (encoding != NULL) {
@@ -1051,6 +1072,8 @@ htmlSaveFileFormat(const char *filename, xmlDocPtr cur,
     xmlCharEncodingHandlerPtr handler = NULL;
     int ret;
 
+    xmlInitParser();
+
     if (encoding != NULL) {
        xmlCharEncoding enc;