Roll libxml from a46e85f6 to dea91c97

Bug: 934413
Change-Id: I45639a7fe29b7a4ce50547f32e89e486c4e0c1e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3069724
Reviewed-by: Stephen Chenney <schenney@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#908466}
NOKEYCHECK=True
GitOrigin-RevId: 2ae577a01307a2c4c7ea1bd57eaa0c561e93bf98
diff --git a/README.chromium b/README.chromium
index 73f68be..1d1d773 100644
--- a/README.chromium
+++ b/README.chromium
@@ -1,6 +1,6 @@
 Name: libxml
 URL: http://xmlsoft.org
-Version: a46e85f6698af712dc8bee683431c70d35e456ff
+Version: dea91c97debeac7c1aaf9c19f79029809e23a353
 CPEPrefix: cpe:/a:xmlsoft:libxml2:2.9.12
 License: MIT
 License File: src/Copyright
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b4c0c79..073869f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,6 +1,16 @@
 cmake_minimum_required(VERSION 3.15)
 
-project(libxml2 VERSION 2.9.12 LANGUAGES C)
+file(STRINGS "configure.ac" CONFIGURE_AC_LINES)
+foreach(line ${CONFIGURE_AC_LINES})
+	if(line MATCHES [[^m4_define\(\[(MAJOR_VERSION|MINOR_VERSION|MICRO_VERSION)\],[ \t]*([0-9]+)\)$]])
+		set(LIBXML_${CMAKE_MATCH_1} ${CMAKE_MATCH_2})
+	elseif(line MATCHES "^(LIBXML_MAJOR_VERSION|LIBXML_MINOR_VERSION|LIBXML_MICRO_VERSION)=([0-9]+)$")
+		set(${CMAKE_MATCH_1} ${CMAKE_MATCH_2})
+	endif()
+endforeach()
+set(VERSION "${LIBXML_MAJOR_VERSION}.${LIBXML_MINOR_VERSION}.${LIBXML_MICRO_VERSION}")
+
+project(libxml2 VERSION ${VERSION} LANGUAGES C)
 
 include(CheckCSourceCompiles)
 include(CheckFunctionExists)
@@ -95,11 +105,6 @@
 	endif()
 endforeach()
 
-set(LIBXML_MAJOR_VERSION ${PROJECT_VERSION_MAJOR})
-set(LIBXML_MINOR_VERSION ${PROJECT_VERSION_MINOR})
-set(LIBXML_MICRO_VERSION ${PROJECT_VERSION_PATCH})
-
-set(VERSION "${LIBXML_MAJOR_VERSION}.${LIBXML_MINOR_VERSION}.${LIBXML_MICRO_VERSION}")
 set(LIBXML_VERSION ${LIBXML_MAJOR_VERSION}0${LIBXML_MINOR_VERSION}0${LIBXML_MICRO_VERSION})
 set(LIBXML_VERSION_STRING "${LIBXML_VERSION}")
 set(LIBXML_VERSION_EXTRA "")
diff --git a/src/HTMLtree.c b/src/HTMLtree.c
index bdd639c..7a2b855 100644
--- a/src/HTMLtree.c
+++ b/src/HTMLtree.c
@@ -763,11 +763,15 @@
             if (((xmlDocPtr) cur)->intSubset != NULL) {
                 htmlDtdDumpOutput(buf, (xmlDocPtr) cur, NULL);
             }
-            /* Always validate cur->parent when descending. */
-            if ((cur->parent == parent) && (cur->children != NULL)) {
-                parent = cur;
-                cur = cur->children;
-                continue;
+            if (cur->children != NULL) {
+                /* Always validate cur->parent when descending. */
+                if (cur->parent == parent) {
+                    parent = cur;
+                    cur = cur->children;
+                    continue;
+                }
+            } else {
+                xmlOutputBufferWriteString(buf, "\n");
             }
             break;
 
diff --git a/src/libxml2.spec b/src/libxml2.spec
index 682dff2..b3eca4f 100644
--- a/src/libxml2.spec
+++ b/src/libxml2.spec
@@ -204,6 +204,6 @@
 %endif # with_python3
 
 %changelog
-* Mon May 24 2021 Daniel Veillard <veillard@redhat.com>
+* Tue Aug  3 2021 Daniel Veillard <veillard@redhat.com>
 - upstream release 2.9.12 see http://xmlsoft.org/news.html
 
diff --git a/src/xmlIO.c b/src/xmlIO.c
index 57312b9..f20c0fa 100644
--- a/src/xmlIO.c
+++ b/src/xmlIO.c
@@ -3401,12 +3401,18 @@
 		out->error = XML_IO_ENCODER;
 		return(-1);
 	    }
-            nbchars = ret >= 0 ? ret : 0;
+            if (out->writecallback)
+	        nbchars = xmlBufUse(out->conv);
+            else
+                nbchars = ret >= 0 ? ret : 0;
 	} else {
 	    ret = xmlBufAdd(out->buffer, (const xmlChar *) buf, chunk);
 	    if (ret != 0)
 	        return(-1);
-            nbchars = chunk;
+            if (out->writecallback)
+	        nbchars = xmlBufUse(out->buffer);
+            else
+                nbchars = chunk;
 	}
 	buf += chunk;
 	len -= chunk;
@@ -3593,13 +3599,19 @@
 		out->error = XML_IO_ENCODER;
 		return(-1);
 	    }
-            nbchars = ret >= 0 ? ret : 0;
+            if (out->writecallback)
+	        nbchars = xmlBufUse(out->conv);
+            else
+                nbchars = ret >= 0 ? ret : 0;
 	} else {
 	    ret = escaping(xmlBufEnd(out->buffer), &chunk, str, &cons);
 	    if ((ret < 0) || (chunk == 0)) /* chunk==0 => nothing done */
 	        return(-1);
             xmlBufAddLen(out->buffer, chunk);
-            nbchars = chunk;
+            if (out->writecallback)
+	        nbchars = xmlBufUse(out->buffer);
+            else
+                nbchars = chunk;
 	}
 	str += cons;
 	len -= cons;
diff --git a/src/xmlsave.c b/src/xmlsave.c
index aedbd5e..489505f 100644
--- a/src/xmlsave.c
+++ b/src/xmlsave.c
@@ -890,6 +890,13 @@
             break;
 
         case XML_ELEMENT_NODE:
+	    if ((cur != root) && (ctxt->format == 1) &&
+                (xmlIndentTreeOutput))
+		xmlOutputBufferWrite(buf, ctxt->indent_size *
+				     (ctxt->level > ctxt->indent_nr ?
+				      ctxt->indent_nr : ctxt->level),
+				     ctxt->indent);
+
             /*
              * Some users like lxml are known to pass nodes with a corrupted
              * tree structure. Fall back to a recursive call to handle this
@@ -900,13 +907,6 @@
                 break;
             }
 
-	    if ((ctxt->level > 0) && (ctxt->format == 1) &&
-                (xmlIndentTreeOutput))
-		xmlOutputBufferWrite(buf, ctxt->indent_size *
-				     (ctxt->level > ctxt->indent_nr ?
-				      ctxt->indent_nr : ctxt->level),
-				     ctxt->indent);
-
             xmlOutputBufferWrite(buf, 1, "<");
             if ((cur->ns != NULL) && (cur->ns->prefix != NULL)) {
                 xmlOutputBufferWriteString(buf, (const char *)cur->ns->prefix);
diff --git a/src/xpath.c b/src/xpath.c
index 711bd2a..d9e9408 100644
--- a/src/xpath.c
+++ b/src/xpath.c
@@ -10983,7 +10983,7 @@
     }
 
     if (xpctxt != NULL)
-        xpctxt->depth -= 1;
+        xpctxt->depth -= 10;
 }
 
 /**