https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f7671c1be8e87d60ecf4dac8373eac282f24b7ef

commit f7671c1be8e87d60ecf4dac8373eac282f24b7ef
Author:     Thomas Faber <[email protected]>
AuthorDate: Sat Nov 19 15:08:52 2022 -0500
Commit:     Thomas Faber <[email protected]>
CommitDate: Mon Nov 21 19:46:11 2022 -0500

    [LIBXSLT] Update to version 1.1.35. CORE-17766
---
 dll/3rdparty/libxslt/Makefile.am                 |   4 +
 dll/3rdparty/libxslt/NEWS                        | 171 ++++++++-
 dll/3rdparty/libxslt/README                      |   4 +-
 dll/3rdparty/libxslt/extensions.c                |   6 -
 dll/3rdparty/libxslt/functions.c                 |  14 +-
 dll/3rdparty/libxslt/libxslt.3                   |   2 +-
 dll/3rdparty/libxslt/numbers.c                   |   4 +-
 dll/3rdparty/libxslt/pattern.c                   | 464 ++++++++++-------------
 dll/3rdparty/libxslt/preproc.c                   |   2 +
 dll/3rdparty/libxslt/preproc.h                   |   2 +-
 dll/3rdparty/libxslt/security.c                  |   2 +-
 dll/3rdparty/libxslt/templates.c                 |   8 +
 dll/3rdparty/libxslt/transform.c                 | 124 +-----
 dll/3rdparty/libxslt/xslt.c                      |   8 +-
 dll/3rdparty/libxslt/xsltlocale.c                |   3 +-
 dll/3rdparty/libxslt/xsltutils.c                 |  59 ++-
 dll/3rdparty/libxslt/xsltwin32config.h           |   6 +-
 media/doc/3rd Party Files.txt                    |   2 +-
 sdk/include/reactos/libs/libxslt/extensions.h    |   2 +-
 sdk/include/reactos/libs/libxslt/xsltInternals.h |  26 +-
 sdk/include/reactos/libs/libxslt/xsltconfig.h    |   6 +-
 21 files changed, 482 insertions(+), 437 deletions(-)

diff --git a/dll/3rdparty/libxslt/Makefile.am b/dll/3rdparty/libxslt/Makefile.am
index 2c417d0be23..a7b13f898cc 100644
--- a/dll/3rdparty/libxslt/Makefile.am
+++ b/dll/3rdparty/libxslt/Makefile.am
@@ -25,6 +25,7 @@ EXTRA_DIST = xsltConf.sh.in xslt-config.in libxslt.spec 
libxslt.spec.in \
              FEATURES TODO Copyright libxslt.m4 \
             win32/libxslt/libxslt.def win32/libxslt/libxslt.dsw \
             win32/libxslt/libxslt_so.dsp win32/libxslt/xsltproc.dsp \
+            CMakeLists.txt config.h.cmake.in FindGcrypt.cmake 
libxslt-config.cmake.in libxslt-config.cmake.cmake.in \
             $(CVS_EXTRA_DIST)
 
 ## We create xsltConf.sh here and not from configure because we want
@@ -73,6 +74,9 @@ rpm: cleantar
 pkgconfigdir=$(libdir)/pkgconfig
 pkgconfig_DATA = libxslt.pc libexslt.pc
 
+cmakedir = $(libdir)/cmake/libxslt
+cmake_DATA = FindGcrypt.cmake libxslt-config.cmake
+
 m4datadir = $(datadir)/aclocal
 m4data_DATA = libxslt.m4
 
diff --git a/dll/3rdparty/libxslt/NEWS b/dll/3rdparty/libxslt/NEWS
index 7200cd33f8e..609e961568e 100644
--- a/dll/3rdparty/libxslt/NEWS
+++ b/dll/3rdparty/libxslt/NEWS
@@ -1,13 +1,176 @@
 
         NEWS file for libxslt
 
-  Note that this is automatically generated from the news webpage at:
-       http://xmlsoft.org/XSLT/news.html
-
 See the git page at 
 https://gitlab.gnome.org/GNOME/libxslt
 
-to get a description of the recent commits.Those are the public releases made:
+to get a description of the recent commits.
+v1.1.35: Feb 16 2022:
+   - Security:
+  [CVE-2021-30560] Fix use-after-free in xsltApplyTemplates
+  Fix memory leak in xsltDocumentElem (David King)
+  Fix memory leak in xsltCompileIdKeyPattern (David King)
+  Fix double-free with stylesheets containing entity nodes
+  
+   - Fixed regressions:
+  Fix performance regression with predicates in patterns
+  Fix regression in xsltComputeSortResult
+  
+   - Bug fixes:
+  Fix conflict resolution for templates with same priority
+  Fix xsl:number generating invalid UTF-8
+  Support attribute value templates in xsl:sort lang attributes
+  Don't pass first <xsl:sort> in <xsl:apply-templates> twice
+  Fix quadratic runtime with text and <xsl:message>
+  Don't allow empty EXSLT durations
+  
+   - Improvements:
+  Add xsltproc --huge Argument via libxml XML_PARSE_HUGE (William N. Braswell, 
Jr.)
+  
+   - Tests, code quality, fuzzing:
+  Remove .travis.yml
+  Fix some misleading indentation (David King)
+  Use actual types for templates in struct _xsltStylesheet
+  Add CI for CMake on MSVC (Markus Rickert)
+  Check for null pointer before calling freelocale
+  Add CI test for Python 3
+  Don't set maxDepth in XPath contexts
+  Transfer XPath limits to XPtr context
+  Stop using maxParserDepth XPath limit
+  Make long-to-double cast explicit in date.c
+  Disable LeakSanitizer
+  Run clang CI tests with -Wimplicit-int-conversion
+  Fix implicit-int-conversion warning in exslt/crypto.c
+  Fix clang -Wimplicit-int-conversion warning (David Kilzer)
+  Fix clang -Wconditional-uninitialized warning in libxslt/numbers.c (David 
Kilzer)
+  Fix -Wshadow warnings in libexslt/dynamic.c (David Kilzer)
+  Also search parent dir for source XML when fuzzing
+  
+   - Build system, portability:
+  Add CMake build files (Markus Rickert)
+  Initial support for Python 3 (Suleyman Poyraz)
+  Call ANSI versions of WinAPI functions explicitly
+  Remove redundant flags from pkg-config files
+  Suppress automake warning in tests/XSLTMark
+  Fix linking libexslt dynamic library when using MinGW (Vadim Zeitlin)
+  Added platform specific path separators (Dmitriy Korovkin)
+  win32: allow passing *FLAGS on command line
+  Fix export of xsltExtMarker on Windows (David Kilzer)
+  Fix redundant includes already in libexslt.h (David Kilzer)
+  Minor fixes to configure.js
+  Fix variable syntax in Python configuration
+  Add new EXSLT string tests to EXTRA_DIST
+  Fix xml2-config check in configure script
+  win32: Add configuration for profiler (Chun-wei Fan)
+  Check whether 'xml2-config --dynamic' is supported
+  
+   - Documentation:
+  Add Makefile rule to regenerate xsltproc.html
+  Update links
+  Remove MAINTAINERS
+  Upload documentation to GitLab Pages
+  Add documentation in devhelp format
+  Add --enable-rebuild-docs configure option
+  Fix libexslt header summaries
+  Fix validity of tutorial XML (David King)
+  Use DocBook URL for tutorial DTD (David King)
+  Update libxslt.doap
+  Add missing options to xsltproc man page
+  
+
+
+v1.1.34: Oct 30 2019:
+   - Documentation:
+  Fix EXSLT web pages (Nick Wellnhofer),
+  Regenerate web pages (Nick Wellnhofer),
+  Fix Git link in news.html (Nick Wellnhofer),
+  Minor documentation fixes after recent changes (Nick Wellnhofer),
+  Fix typos (Jan Pokorn�),
+  Regenerate symbols and API docs (Nick Wellnhofer),
+  Regenerate EXSLT website (Nick Wellnhofer)
+  
+   - Portability:
+  Remove stubs when compiling without debugger or profiler (Nick Wellnhofer),
+  configure.ac: Invoke PKG_CHECK_MODULES for building shared libraries (Hugh 
McMaster),
+  configure.ac: Conditionally determine whether xml2-config should pass shared 
libraries or static libraries (Hugh McMaster),
+  xslt-config.in: Fix broken --prefix=DIR support (Hugh McMaster),
+  libexslt.pc.in: Do not expose private library  dependencies unless invoked 
(Hugh McMaster),
+  libxslt.pc.in: Do not expose private library dependencies  unless invoked 
(Hugh McMaster),
+  Fix -Wformat-overflow warning (GCC 9) (Nick Wellnhofer),
+  Stop including ansidecl.h (Nick Wellnhofer),
+  Remove WIN32_EXTRA_* variables (Nick Wellnhofer),
+  Fix vsnprintf in Python bindings on Windows (Nick Wellnhofer),
+  Build without winsock (Nick Wellnhofer),
+  Stop redefining snprintf on MinGW (Nick Wellnhofer)
+  
+   - Bug Fixes:
+  xsl:template without name and match attributes should not be allowed 
(Nikolai Weibull),
+  Make sure that Python tests exit with error code (Nick Wellnhofer),
+  Improve handling of invalid UTF-8 in format-number (Nick Wellnhofer),
+  Fix dangling pointer in xsltCopyText (Nick Wellnhofer),
+  Fix memory leak in pattern compilation error path (Nick Wellnhofer),
+  Fix uninitialized read with UTF-8 grouping chars (Nick Wellnhofer),
+  Fix integer overflow in FORMAT_GYEAR (Nick Wellnhofer),
+  Fix performance regression with xsl:number (Nick Wellnhofer),
+  Backup XPath context node in xsltInitCtxtKey (Nick Wellnhofer),
+  Fix unsigned integer overflow in date.c (Nick Wellnhofer),
+  Fix insertion of xsl:fallback content (Nick Wellnhofer),
+  Avoid quadratic behavior in xsltSaveResultTo (Nick Wellnhofer),
+  Fix numbering in non-Latin scripts (Nick Wellnhofer),
+  Fix uninitialized read of xsl:number token (Nick Wellnhofer),
+  Fix integer overflow in _exsltDateDayInWeek (Nick Wellnhofer),
+  Rework xsltAttrVT allocation (Nick Wellnhofer),
+  Fix check of xsltTestCompMatch return value (Nick Wellnhofer),
+  Fix security framework bypass (Nick Wellnhofer),
+  Use xmlNewTextChild in EXSLT dyn:map (Nick Wellnhofer),
+  Fix float casts in exsltDateDuration (Nick Wellnhofer),
+  Always set context node before calling XPath iterators (Nick Wellnhofer),
+  Fix attribute precedence with xsl:use-attribute-sets (Nick Wellnhofer),
+  Backup context node in exsltFuncFunctionFunction (Nick Wellnhofer),
+  Initialize ctxt->output before evaluating global vars (Nick Wellnhofer),
+  Fix memory leak in EXSLT functions error path (Nick Wellnhofer)
+  
+   - Improvements:
+  Enable continuous integration via GitLab CI (Nick Wellnhofer),
+  Fix -Wimplicit-fallthrough warnings (Nick Wellnhofer),
+  Adjust number of API index pages (Nick Wellnhofer),
+  Make xsltCompileRelativePathPattern non-recursive (Nick Wellnhofer),
+  Check that crypto:rc4_decrypt produces valid UTF-8 (Nick Wellnhofer),
+  Avoid recursion in keys.c:skipPredicate (Nick Wellnhofer),
+  xslt-config.in: Simply handling of $all_flags (Hugh McMaster),
+  xslt-config.in: Add a --dynamic option to --libs (Hugh McMaster),
+  xslt-config.in: Simplify basic library handling (Hugh McMaster),
+  xslt-config.in: Remove unused variable (Hugh McMaster),
+  xslt-config: Simply handling of --cflags (Hugh McMaster),
+  Add Travis test with MemorySanitizer (Nick Wellnhofer),
+  Run Travis ASan tests under Xenial (Nick Wellnhofer),
+  Improve fuzzers (Nick Wellnhofer),
+  Always reuse XPath context (Nick Wellnhofer),
+  Compile with -Wextra (Nick Wellnhofer),
+  Make profiler support optional (Nick Wellnhofer),
+  Hide unused code when compiling without debugger (Nick Wellnhofer),
+  Reorganize fuzzing code (Nick Wellnhofer),
+  Simplify .gitignore (Nick Wellnhofer),
+  Optional operation limit (Nick Wellnhofer),
+  Improve seed corpus and dictionary (Nick Wellnhofer),
+  Reuse XPath context when compiling stylesheets (Nick Wellnhofer),
+  Reuse XPath context in dyn:map (Nick Wellnhofer),
+  Reuse XPath context in saxon:expression (Nick Wellnhofer),
+  Add libFuzzer targets (Nick Wellnhofer),
+  Adjust error message in expected test output (Nick Wellnhofer),
+  Change bug tracker URL (Nick Wellnhofer),
+  Change git repo URL (Nick Wellnhofer),
+  Regenerate NEWS (Nick Wellnhofer),
+  Fix misleading indentation in security.c (Nick Wellnhofer)
+  
+   - Cleanups:
+  Candidate release 1 of libxslt 1.1.34 * doc/xsltproc.xml: moved to new place 
for docbook stylesheet and work   around a missing / inrewrite of  docbook xsl 
catalog in Fedora 30 * tests/fuzz/Makefile.am: add fuzz.h to sources * 
python/Makefile.am: there is no more TODO * libxslt.spec.in: run make tests 
instead of check to avoid fuzz in that   environment, and drop python TODO 
(Daniel Veillard),
+  Remove empty TODO file (Nick Wellnhofer),
+  Remove generated file libxsltclass.txt from version control (Nick 
Wellnhofer),
+  Rebuild docs (Nick Wellnhofer)
+  
+
+
 v1.1.33: Jan 03 2019:
    - Portability:
   Variables need 'extern' in static lib on Cygwin (Nick Wellnhofer),
diff --git a/dll/3rdparty/libxslt/README b/dll/3rdparty/libxslt/README
index 85bf80e5a44..ddb6f28c4f1 100644
--- a/dll/3rdparty/libxslt/README
+++ b/dll/3rdparty/libxslt/README
@@ -2,12 +2,12 @@
      XSLT support for libxml2 (XML toolkit from the GNOME project)
 
 Full documentation is available on-line at
-    http://xmlsoft.org/XSLT/
+    https://gitlab.gnome.org/GNOME/libxslt/-/wikis
 
 This code is released under the MIT Licence see the Copyright file.
  
 To report bugs, follow the instructions at:
-  http://xmlsoft.org/XSLT/bugs.html
+    https://gitlab.gnome.org/GNOME/libxslt/-/issues
 
 A mailing-list [email protected] is available, to subscribe:
     http://mail.gnome.org/mailman/listinfo/xslt
diff --git a/dll/3rdparty/libxslt/extensions.c 
b/dll/3rdparty/libxslt/extensions.c
index 4fcf69c4efd..bbc4e115721 100644
--- a/dll/3rdparty/libxslt/extensions.c
+++ b/dll/3rdparty/libxslt/extensions.c
@@ -1951,12 +1951,6 @@ xsltGetExtInfo(xsltStylesheetPtr style, const xmlChar * 
URI)
     return NULL;
 }
 
-/************************************************************************
- *                                                                     *
- *             Test module http://xmlsoft.org/XSLT/                    *
- *                                                                     *
- ************************************************************************/
-
 /************************************************************************
  *                                                                     *
  *             Test of the extension module API                        *
diff --git a/dll/3rdparty/libxslt/functions.c b/dll/3rdparty/libxslt/functions.c
index 306044ce930..0c6e10f1957 100644
--- a/dll/3rdparty/libxslt/functions.c
+++ b/dll/3rdparty/libxslt/functions.c
@@ -150,10 +150,22 @@ xsltDocumentFunctionLoadDocument(xmlXPathParserContextPtr 
ctxt, xmlChar* URI)
        goto out_fragment;
     }
 
+#if LIBXML_VERSION >= 20911 || \
+    defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
+    xptrctxt->opLimit = ctxt->context->opLimit;
+    xptrctxt->opCount = ctxt->context->opCount;
+    xptrctxt->depth = ctxt->context->depth;
+
+    resObj = xmlXPtrEval(fragment, xptrctxt);
+
+    ctxt->context->opCount = xptrctxt->opCount;
+#else
     resObj = xmlXPtrEval(fragment, xptrctxt);
-    xmlXPathFreeContext(xptrctxt);
 #endif
 
+    xmlXPathFreeContext(xptrctxt);
+#endif /* LIBXML_XPTR_ENABLED */
+
     if (resObj == NULL)
        goto out_fragment;
 
diff --git a/dll/3rdparty/libxslt/libxslt.3 b/dll/3rdparty/libxslt/libxslt.3
index 06f256d4b74..f6f855db9aa 100644
--- a/dll/3rdparty/libxslt/libxslt.3
+++ b/dll/3rdparty/libxslt/libxslt.3
@@ -21,7 +21,7 @@ binary application to do XSL transformations on the command 
line
 .SH AUTHORS
 Daniel Veillard ([email protected]).
 If you download and install this package look at instructions on the
-Web site http://xmlsoft.org/XSLT/ .
+Web site https://gitlab.gnome.org/GNOME/libxslt .
 Manual page by Heiko W. Rupp ([email protected])
 .SH SEE ALSO
 .IR libexslt (3), 
diff --git a/dll/3rdparty/libxslt/numbers.c b/dll/3rdparty/libxslt/numbers.c
index a77d15a07a5..eee53d56227 100644
--- a/dll/3rdparty/libxslt/numbers.c
+++ b/dll/3rdparty/libxslt/numbers.c
@@ -160,7 +160,7 @@ xsltNumberFormatDecimal(xmlBufferPtr buffer,
                i = -1;
                break;
            }
-           *(--pointer) = val;
+           *(--pointer) = (xmlChar)val;
        }
        else {
        /*
@@ -943,7 +943,7 @@ xsltFormatNumberConversion(xsltDecimalFormatPtr self,
     xmlChar *nprefix, *nsuffix = NULL;
     int            prefix_length, suffix_length = 0, nprefix_length, 
nsuffix_length;
     double  scale;
-    int            j, len;
+    int            j, len = 0;
     int     self_grouping_len;
     xsltFormatNumberInfo format_info;
     /*
diff --git a/dll/3rdparty/libxslt/pattern.c b/dll/3rdparty/libxslt/pattern.c
index 8741b46a6a7..91f5eed4201 100644
--- a/dll/3rdparty/libxslt/pattern.c
+++ b/dll/3rdparty/libxslt/pattern.c
@@ -433,14 +433,11 @@ xsltReverseCompMatch(xsltParserContextPtr ctxt, 
xsltCompMatchPtr comp) {
     xsltCompMatchAdd(ctxt, comp, XSLT_OP_END, NULL, NULL, 0);
 
     /*
-     * Detect consecutive XSLT_OP_PREDICATE and predicates on ops which
-     * haven't been optimized yet indicating a direct matching should be done.
+     * Detect consecutive XSLT_OP_PREDICATE indicating a direct matching
+     * should be done.
      */
     for (i = 0;i < comp->nbStep - 1;i++) {
-        xsltOp op = comp->steps[i].op;
-
-        if ((op != XSLT_OP_ELEM) &&
-            (op != XSLT_OP_ALL) &&
+        if ((comp->steps[i].op == XSLT_OP_PREDICATE) &&
            (comp->steps[i + 1].op == XSLT_OP_PREDICATE)) {
 
            comp->direct = 1;
@@ -610,6 +607,152 @@ xsltTestCompMatchDirect(xsltTransformContextPtr ctxt, 
xsltCompMatchPtr comp,
     return(0);
 }
 
+/**
+ * xsltTestStepMatch:
+ * @ctxt:  a XSLT process context
+ * @node: a node
+ * @step:  the step
+ *
+ * Test whether the node matches the step.
+ *
+ * Returns 1 if it matches, 0 if it doesn't and -1 in case of failure
+ */
+static int
+xsltTestStepMatch(xsltTransformContextPtr ctxt, xmlNodePtr node,
+                  xsltStepOpPtr step) {
+    switch (step->op) {
+        case XSLT_OP_ROOT:
+            if ((node->type == XML_DOCUMENT_NODE) ||
+#ifdef LIBXML_DOCB_ENABLED
+                (node->type == XML_DOCB_DOCUMENT_NODE) ||
+#endif
+                (node->type == XML_HTML_DOCUMENT_NODE))
+                return(1);
+            if ((node->type == XML_ELEMENT_NODE) && (node->name[0] == ' '))
+                return(1);
+            return(0);
+        case XSLT_OP_ELEM:
+            if (node->type != XML_ELEMENT_NODE)
+                return(0);
+            if (step->value == NULL)
+                return(1);
+            if (step->value[0] != node->name[0])
+                return(0);
+            if (!xmlStrEqual(step->value, node->name))
+                return(0);
+
+            /* Namespace test */
+            if (node->ns == NULL) {
+                if (step->value2 != NULL)
+                    return(0);
+            } else if (node->ns->href != NULL) {
+                if (step->value2 == NULL)
+                    return(0);
+                if (!xmlStrEqual(step->value2, node->ns->href))
+                    return(0);
+            }
+            return(1);
+        case XSLT_OP_ATTR:
+            if (node->type != XML_ATTRIBUTE_NODE)
+                return(0);
+            if (step->value != NULL) {
+                if (step->value[0] != node->name[0])
+                    return(0);
+                if (!xmlStrEqual(step->value, node->name))
+                    return(0);
+            }
+            /* Namespace test */
+            if (node->ns == NULL) {
+                if (step->value2 != NULL)
+                    return(0);
+            } else if (step->value2 != NULL) {
+                if (!xmlStrEqual(step->value2, node->ns->href))
+                    return(0);
+            }
+            return(1);
+        case XSLT_OP_ID: {
+            /* TODO Handle IDs decently, must be done differently */
+            xmlAttrPtr id;
+
+            if (node->type != XML_ELEMENT_NODE)
+                return(0);
+
+            id = xmlGetID(node->doc, step->value);
+            if ((id == NULL) || (id->parent != node))
+                return(0);
+            break;
+        }
+        case XSLT_OP_KEY: {
+            xmlNodeSetPtr list;
+            int indx;
+
+            list = xsltGetKey(ctxt, step->value,
+                              step->value3, step->value2);
+            if (list == NULL)
+                return(0);
+            for (indx = 0;indx < list->nodeNr;indx++)
+                if (list->nodeTab[indx] == node)
+                    break;
+            if (indx >= list->nodeNr)
+                return(0);
+            break;
+        }
+        case XSLT_OP_NS:
+            if (node->type != XML_ELEMENT_NODE)
+                return(0);
+            if (node->ns == NULL) {
+                if (step->value != NULL)
+                    return(0);
+            } else if (node->ns->href != NULL) {
+                if (step->value == NULL)
+                    return(0);
+                if (!xmlStrEqual(step->value, node->ns->href))
+                    return(0);
+            }
+            break;
+        case XSLT_OP_ALL:
+            if (node->type != XML_ELEMENT_NODE)
+                return(0);
+            break;
+        case XSLT_OP_PI:
+            if (node->type != XML_PI_NODE)
+                return(0);
+            if (step->value != NULL) {
+                if (!xmlStrEqual(step->value, node->name))
+                    return(0);
+            }
+            break;
+        case XSLT_OP_COMMENT:
+            if (node->type != XML_COMMENT_NODE)
+                return(0);
+            break;
+        case XSLT_OP_TEXT:
+            if ((node->type != XML_TEXT_NODE) &&
+                (node->type != XML_CDATA_SECTION_NODE))
+                return(0);
+            break;
+        case XSLT_OP_NODE:
+            switch (node->type) {
+                case XML_ELEMENT_NODE:
+                case XML_CDATA_SECTION_NODE:
+                case XML_PI_NODE:
+                case XML_COMMENT_NODE:
+                case XML_TEXT_NODE:
+                    break;
+                default:
+                    return(0);
+            }
+            break;
+        default:
+            xsltTransformError(ctxt, NULL, node,
+                    "xsltTestStepMatch: unexpected step op %d\n",
+                    step->op);
+            return(-1);
+    }
+
+    return(1);
+}
+
 /**
  * xsltTestPredicateMatch:
  * @ctxt: a XSLT process context
@@ -637,6 +780,8 @@ xsltTestPredicateMatch(xsltTransformContextPtr ctxt, 
xsltCompMatchPtr comp,
         return(0);
     if (step->comp == NULL)
         return(0);
+    if (sel == NULL)
+        return(0);
 
     doc = node->doc;
     if (XSLT_IS_RES_TREE_FRAG(doc))
@@ -647,16 +792,16 @@ xsltTestPredicateMatch(xsltTransformContextPtr ctxt, 
xsltCompMatchPtr comp,
     /*
      * Recompute contextSize and proximityPosition.
      *
-     * TODO: Make this work for additional ops. Currently, only XSLT_OP_ELEM
-     * and XSLT_OP_ALL are supported.
+     * This could be improved in the following ways:
+     *
+     * - Skip recomputation if predicates don't use position() or last()
+     * - Keep data for multiple parents. This would require a hash table
+     *   or an unused member in xmlNode.
+     * - Store node test results in a bitmap to avoid computing them twice.
      */
     oldCS = ctxt->xpathCtxt->contextSize;
     oldCP = ctxt->xpathCtxt->proximityPosition;
-    if ((sel != NULL) &&
-        (sel->op == XSLT_OP_ELEM) &&
-        (sel->value != NULL) &&
-        (node->type == XML_ELEMENT_NODE) &&
-        (node->parent != NULL)) {
+    {
         xmlNodePtr previous;
         int nocache = 0;
 
@@ -673,17 +818,8 @@ xsltTestPredicateMatch(xsltTransformContextPtr ctxt, 
xsltCompMatchPtr comp,
             while (sibling != NULL) {
                 if (sibling == previous)
                     break;
-                if ((sibling->type == XML_ELEMENT_NODE) &&
-                    (previous->name != NULL) &&
-                    (sibling->name != NULL) &&
-                    (previous->name[0] == sibling->name[0]) &&
-                    (xmlStrEqual(previous->name, sibling->name)))
-                {
-                    if ((sel->value2 == NULL) ||
-                        ((sibling->ns != NULL) &&
-                         (xmlStrEqual(sel->value2, sibling->ns->href))))
-                        indx++;
-                }
+                if (xsltTestStepMatch(ctxt, sibling, sel))
+                    indx++;
                 sibling = sibling->prev;
             }
             if (sibling == NULL) {
@@ -693,20 +829,8 @@ xsltTestPredicateMatch(xsltTransformContextPtr ctxt, 
xsltCompMatchPtr comp,
                 while (sibling != NULL) {
                     if (sibling == previous)
                         break;
-                    if ((sibling->type == XML_ELEMENT_NODE) &&
-                        (previous->name != NULL) &&
-                        (sibling->name != NULL) &&
-                        (previous->name[0] == sibling->name[0]) &&
-                        (xmlStrEqual(previous->name, sibling->name)))
-                    {
-                        if ((sel->value2 == NULL) ||
-                            ((sibling->ns != NULL) &&
-                            (xmlStrEqual(sel->value2,
-                            sibling->ns->href))))
-                        {
-                            indx--;
-                        }
-                    }
+                    if (xsltTestStepMatch(ctxt, sibling, sel))
+                        indx--;
                     sibling = sibling->next;
                 }
             }
@@ -737,19 +861,11 @@ xsltTestPredicateMatch(xsltTransformContextPtr ctxt, 
xsltCompMatchPtr comp,
             if (parent) siblings = parent->children;
 
             while (siblings != NULL) {
-                if (siblings->type == XML_ELEMENT_NODE) {
-                    if (siblings == node) {
-                        len++;
-                        pos = len;
-                    } else if ((node->name != NULL) &&
-                               (siblings->name != NULL) &&
-                        (node->name[0] == siblings->name[0]) &&
-                        (xmlStrEqual(node->name, siblings->name))) {
-                        if ((sel->value2 == NULL) ||
-                            ((siblings->ns != NULL) &&
-                             (xmlStrEqual(sel->value2, siblings->ns->href))))
-                            len++;
-                    }
+                if (siblings == node) {
+                    len++;
+                    pos = len;
+                } else if (xsltTestStepMatch(ctxt, siblings, sel)) {
+                    len++;
                 }
                 siblings = siblings->next;
             }
@@ -778,96 +894,6 @@ xsltTestPredicateMatch(xsltTransformContextPtr ctxt, 
xsltCompMatchPtr comp,
                 XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival) = len;
             }
         }
-    } else if ((sel != NULL) && (sel->op == XSLT_OP_ALL) &&
-               (node->type == XML_ELEMENT_NODE)) {
-        xmlNodePtr previous;
-        int nocache = 0;
-
-        previous = (xmlNodePtr)
-            XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr);
-        if ((previous != NULL) &&
-            (previous->parent == node->parent)) {
-            /*
-             * just walk back to adjust the index
-             */
-            int indx = 0;
-            xmlNodePtr sibling = node;
-
-            while (sibling != NULL) {
-                if (sibling == previous)
-                    break;
-                if (sibling->type == XML_ELEMENT_NODE)
-                    indx++;
-                sibling = sibling->prev;
-            }
-            if (sibling == NULL) {
-                /* hum going backward in document order ... */
-                indx = 0;
-                sibling = node;
-                while (sibling != NULL) {
-                    if (sibling == previous)
-                        break;
-                    if (sibling->type == XML_ELEMENT_NODE)
-                        indx--;
-                    sibling = sibling->next;
-                }
-            }
-            if (sibling != NULL) {
-                pos = XSLT_RUNTIME_EXTRA(ctxt,
-                    sel->indexExtra, ival) + indx;
-                /*
-                 * If the node is in a Value Tree we cannot
-                 * cache it !
-                 */
-                if ((node->doc != NULL) && !isRVT) {
-                    len = XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival);
-                    XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) = node;
-                    XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) = pos;
-                }
-            } else
-                pos = 0;
-        } else {
-            /*
-             * recompute the index
-             */
-            xmlNodePtr parent = node->parent;
-            xmlNodePtr siblings = NULL;
-
-            if (parent) siblings = parent->children;
-
-            while (siblings != NULL) {
-                if (siblings->type == XML_ELEMENT_NODE) {
-                    len++;
-                    if (siblings == node) {
-                        pos = len;
-                    }
-                }
-                siblings = siblings->next;
-            }
-            if ((parent == NULL) || (node->doc == NULL))
-                nocache = 1;
-            else {
-                while (parent->parent != NULL)
-                    parent = parent->parent;
-                if (((parent->type != XML_DOCUMENT_NODE) &&
-                     (parent->type != XML_HTML_DOCUMENT_NODE)) ||
-                     (parent != (xmlNodePtr) node->doc))
-                    nocache = 1;
-            }
-        }
-        if (pos != 0) {
-            ctxt->xpathCtxt->contextSize = len;
-            ctxt->xpathCtxt->proximityPosition = pos;
-            /*
-             * If the node is in a Value Tree we cannot
-             * cache it !
-             */
-            if ((node->doc != NULL) && (nocache == 0) && !isRVT) {
-                XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) = node;
-                XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) = pos;
-                XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival) = len;
-            }
-        }
     }
 
     oldNode = ctxt->node;
@@ -950,55 +976,6 @@ restart:
        switch (step->op) {
             case XSLT_OP_END:
                goto found;
-            case XSLT_OP_ROOT:
-               if ((node->type == XML_DOCUMENT_NODE) ||
-#ifdef LIBXML_DOCB_ENABLED
-                   (node->type == XML_DOCB_DOCUMENT_NODE) ||
-#endif
-                   (node->type == XML_HTML_DOCUMENT_NODE))
-                   continue;
-               if ((node->type == XML_ELEMENT_NODE) && (node->name[0] == ' '))
-                   continue;
-               goto rollback;
-            case XSLT_OP_ELEM:
-               if (node->type != XML_ELEMENT_NODE)
-                   goto rollback;
-               if (step->value == NULL)
-                   continue;
-               if (step->value[0] != node->name[0])
-                   goto rollback;
-               if (!xmlStrEqual(step->value, node->name))
-                   goto rollback;
-
-               /* Namespace test */
-               if (node->ns == NULL) {
-                   if (step->value2 != NULL)
-                       goto rollback;
-               } else if (node->ns->href != NULL) {
-                   if (step->value2 == NULL)
-                       goto rollback;
-                   if (!xmlStrEqual(step->value2, node->ns->href))
-                       goto rollback;
-               }
-               continue;
-            case XSLT_OP_ATTR:
-               if (node->type != XML_ATTRIBUTE_NODE)
-                   goto rollback;
-               if (step->value != NULL) {
-                   if (step->value[0] != node->name[0])
-                       goto rollback;
-                   if (!xmlStrEqual(step->value, node->name))
-                       goto rollback;
-               }
-               /* Namespace test */
-               if (node->ns == NULL) {
-                   if (step->value2 != NULL)
-                       goto rollback;
-               } else if (step->value2 != NULL) {
-                   if (!xmlStrEqual(step->value2, node->ns->href))
-                       goto rollback;
-               }
-               continue;
             case XSLT_OP_PARENT:
                if ((node->type == XML_DOCUMENT_NODE) ||
                    (node->type == XML_HTML_DOCUMENT_NODE) ||
@@ -1056,6 +1033,7 @@ restart:
                    continue;
                }
                i++;
+                sel = step;
                if (step->value == NULL) {
                    xsltPatPushState(ctxt, &states, i - 1, node);
                    continue;
@@ -1080,50 +1058,6 @@ restart:
                    goto rollback;
                xsltPatPushState(ctxt, &states, i - 1, node);
                continue;
-            case XSLT_OP_ID: {
-               /* TODO Handle IDs decently, must be done differently */
-               xmlAttrPtr id;
-
-               if (node->type != XML_ELEMENT_NODE)
-                   goto rollback;
-
-               id = xmlGetID(node->doc, step->value);
-               if ((id == NULL) || (id->parent != node))
-                   goto rollback;
-               break;
-           }
-            case XSLT_OP_KEY: {
-               xmlNodeSetPtr list;
-               int indx;
-
-               list = xsltGetKey(ctxt, step->value,
-                                 step->value3, step->value2);
-               if (list == NULL)
-                   goto rollback;
-               for (indx = 0;indx < list->nodeNr;indx++)
-                   if (list->nodeTab[indx] == node)
-                       break;
-               if (indx >= list->nodeNr)
-                   goto rollback;
-               break;
-           }
-            case XSLT_OP_NS:
-               if (node->type != XML_ELEMENT_NODE)
-                   goto rollback;
-               if (node->ns == NULL) {
-                   if (step->value != NULL)
-                       goto rollback;
-               } else if (node->ns->href != NULL) {
-                   if (step->value == NULL)
-                       goto rollback;
-                   if (!xmlStrEqual(step->value, node->ns->href))
-                       goto rollback;
-               }
-               break;
-            case XSLT_OP_ALL:
-               if (node->type != XML_ELEMENT_NODE)
-                   goto rollback;
-               break;
            case XSLT_OP_PREDICATE: {
                /*
                 * When there is cascading XSLT_OP_PREDICATE or a predicate
@@ -1143,34 +1077,9 @@ restart:
 
                break;
            }
-            case XSLT_OP_PI:
-               if (node->type != XML_PI_NODE)
-                   goto rollback;
-               if (step->value != NULL) {
-                   if (!xmlStrEqual(step->value, node->name))
-                       goto rollback;
-               }
-               break;
-            case XSLT_OP_COMMENT:
-               if (node->type != XML_COMMENT_NODE)
-                   goto rollback;
-               break;
-            case XSLT_OP_TEXT:
-               if ((node->type != XML_TEXT_NODE) &&
-                   (node->type != XML_CDATA_SECTION_NODE))
-                   goto rollback;
-               break;
-            case XSLT_OP_NODE:
-               switch (node->type) {
-                   case XML_ELEMENT_NODE:
-                   case XML_CDATA_SECTION_NODE:
-                   case XML_PI_NODE:
-                   case XML_COMMENT_NODE:
-                   case XML_TEXT_NODE:
-                       break;
-                   default:
-                       goto rollback;
-               }
+            default:
+                if (xsltTestStepMatch(ctxt, node, step) != 1)
+                    goto rollback;
                break;
        }
     }
@@ -1420,6 +1329,7 @@ xsltCompileIdKeyPattern(xsltParserContextPtr ctxt, 
xmlChar *name,
        if (ctxt->error) {
            xsltTransformError(NULL, NULL, NULL,
                    "xsltCompileIdKeyPattern : Literal expected\n");
+           xmlFree(lit);
            return;
        }
        SKIP_BLANKS;
@@ -1446,6 +1356,7 @@ xsltCompileIdKeyPattern(xsltParserContextPtr ctxt, 
xmlChar *name,
        if (ctxt->error) {
            xsltTransformError(NULL, NULL, NULL,
                    "xsltCompileIdKeyPattern : Literal expected\n");
+           xmlFree(lit);
            return;
        }
        SKIP_BLANKS;
@@ -1487,6 +1398,7 @@ xsltCompileIdKeyPattern(xsltParserContextPtr ctxt, 
xmlChar *name,
            if (ctxt->error) {
                xsltTransformError(NULL, NULL, NULL,
                        "xsltCompileIdKeyPattern : Literal expected\n");
+                xmlFree(lit);
                return;
            }
            SKIP_BLANKS;
@@ -2108,13 +2020,16 @@ xsltAddTemplate(xsltStylesheetPtr style, 
xsltTemplatePtr cur,
      * 'top' will point to style->xxxMatch ptr - declaring as 'void'
      *  avoids gcc 'type-punned pointer' warning.
      */
-    void **top = NULL;
+    xsltCompMatchPtr *top = NULL;
     const xmlChar *name = NULL;
     float priority;              /* the priority */
 
     if ((style == NULL) || (cur == NULL))
        return(-1);
 
+    if (cur->next != NULL)
+        cur->position = cur->next->position + 1;
+
     /* Register named template */
     if (cur->name != NULL) {
         if (style->namedTemplates == NULL) {
@@ -2476,7 +2391,10 @@ xsltGetTemplate(xsltTransformContextPtr ctxt, xmlNodePtr 
node,
                break;
        }
        while ((list != NULL) &&
-              ((ret == NULL)  || (list->priority > priority))) {
+              ((ret == NULL) ||
+                (list->priority > priority) ||
+                ((list->priority == priority) &&
+                 (list->template->position > ret->position)))) {
            if (xsltTestCompMatch(ctxt, list, node,
                                  ctxt->mode, ctxt->modeURI) == 1) {
                ret = list->template;
@@ -2493,7 +2411,10 @@ xsltGetTemplate(xsltTransformContextPtr ctxt, xmlNodePtr 
node,
            (node->type == XML_TEXT_NODE)) {
            list = curstyle->elemMatch;
            while ((list != NULL) &&
-                  ((ret == NULL)  || (list->priority > priority))) {
+                   ((ret == NULL) ||
+                    (list->priority > priority) ||
+                    ((list->priority == priority) &&
+                     (list->template->position > ret->position)))) {
                if (xsltTestCompMatch(ctxt, list, node,
                                      ctxt->mode, ctxt->modeURI) == 1) {
                    ret = list->template;
@@ -2506,7 +2427,10 @@ xsltGetTemplate(xsltTransformContextPtr ctxt, xmlNodePtr 
node,
                   (node->type == XML_COMMENT_NODE)) {
            list = curstyle->elemMatch;
            while ((list != NULL) &&
-                  ((ret == NULL)  || (list->priority > priority))) {
+                   ((ret == NULL) ||
+                    (list->priority > priority) ||
+                    ((list->priority == priority) &&
+                     (list->template->position > ret->position)))) {
                if (xsltTestCompMatch(ctxt, list, node,
                                      ctxt->mode, ctxt->modeURI) == 1) {
                    ret = list->template;
@@ -2521,7 +2445,10 @@ keyed_match:
        if (keyed) {
            list = curstyle->keyMatch;
            while ((list != NULL) &&
-                  ((ret == NULL)  || (list->priority > priority))) {
+                   ((ret == NULL) ||
+                    (list->priority > priority) ||
+                    ((list->priority == priority) &&
+                     (list->template->position > ret->position)))) {
                if (xsltTestCompMatch(ctxt, list, node,
                                      ctxt->mode, ctxt->modeURI) == 1) {
                    ret = list->template;
@@ -2599,8 +2526,7 @@ xsltCleanupTemplates(xsltStylesheetPtr style 
ATTRIBUTE_UNUSED) {
 void
 xsltFreeTemplateHashes(xsltStylesheetPtr style) {
     if (style->templatesHash != NULL)
-       xmlHashFree((xmlHashTablePtr) style->templatesHash,
-                   xsltFreeCompMatchListEntry);
+       xmlHashFree(style->templatesHash, xsltFreeCompMatchListEntry);
     if (style->rootMatch != NULL)
         xsltFreeCompMatchList(style->rootMatch);
     if (style->keyMatch != NULL)
diff --git a/dll/3rdparty/libxslt/preproc.c b/dll/3rdparty/libxslt/preproc.c
index 312a75b4d6a..2cf135e4dbe 100644
--- a/dll/3rdparty/libxslt/preproc.c
+++ b/dll/3rdparty/libxslt/preproc.c
@@ -1470,6 +1470,8 @@ xsltNumberComp(xsltStylesheetPtr style, xmlNodePtr cur) {
         comp->numdata.groupingCharacterLen = xmlStrlen(prop);
        comp->numdata.groupingCharacter =
            xsltGetUTF8Char(prop, &(comp->numdata.groupingCharacterLen));
+        if (comp->numdata.groupingCharacter < 0)
+            comp->numdata.groupingCharacter = 0;
     }
 
     prop = xsltGetCNsProp(style, cur, (const xmlChar *)"grouping-size", 
XSLT_NAMESPACE);
diff --git a/dll/3rdparty/libxslt/preproc.h b/dll/3rdparty/libxslt/preproc.h
index caf464ad10f..2a2fc7e4305 100644
--- a/dll/3rdparty/libxslt/preproc.h
+++ b/dll/3rdparty/libxslt/preproc.h
@@ -22,7 +22,7 @@ extern "C" {
 /*
  * Interfaces
  */
-extern const xmlChar *xsltExtMarker;
+XSLTPUBVAR const xmlChar *xsltExtMarker;
 
 XSLTPUBFUN xsltElemPreCompPtr XSLTCALL
                xsltDocumentComp        (xsltStylesheetPtr style,
diff --git a/dll/3rdparty/libxslt/security.c b/dll/3rdparty/libxslt/security.c
index b54b4543f19..b5f53eb5288 100644
--- a/dll/3rdparty/libxslt/security.c
+++ b/dll/3rdparty/libxslt/security.c
@@ -249,7 +249,7 @@ xsltCheckFilename (const char *path)
 #if defined(_WIN32) && !defined(__CYGWIN__)
     DWORD dwAttrs;
 
-    dwAttrs = GetFileAttributes(path);
+    dwAttrs = GetFileAttributesA(path);
     if (dwAttrs != INVALID_FILE_ATTRIBUTES) {
         if (dwAttrs & FILE_ATTRIBUTE_DIRECTORY) {
             return 2;
diff --git a/dll/3rdparty/libxslt/templates.c b/dll/3rdparty/libxslt/templates.c
index b6255e90b26..2d7a749e296 100644
--- a/dll/3rdparty/libxslt/templates.c
+++ b/dll/3rdparty/libxslt/templates.c
@@ -192,6 +192,8 @@ xsltEvalTemplateString(xsltTransformContextPtr ctxt,
 {
     xmlNodePtr oldInsert, insert = NULL;
     xmlChar *ret;
+    const xmlChar *oldLastText;
+    int oldLastTextSize, oldLastTextUse;
 
     if ((ctxt == NULL) || (contextNode == NULL) || (inst == NULL) ||
         (inst->type != XML_ELEMENT_NODE))
@@ -215,12 +217,18 @@ xsltEvalTemplateString(xsltTransformContextPtr ctxt,
     }
     oldInsert = ctxt->insert;
     ctxt->insert = insert;
+    oldLastText = ctxt->lasttext;
+    oldLastTextSize = ctxt->lasttsize;
+    oldLastTextUse = ctxt->lasttuse;
     /*
     * OPTIMIZE TODO: if inst->children consists only of text-nodes.
     */
     xsltApplyOneTemplate(ctxt, contextNode, inst->children, NULL, NULL);
 
     ctxt->insert = oldInsert;
+    ctxt->lasttext = oldLastText;
+    ctxt->lasttsize = oldLastTextSize;
+    ctxt->lasttuse = oldLastTextUse;
 
     ret = xmlNodeGetContent(insert);
     if (insert != NULL)
diff --git a/dll/3rdparty/libxslt/transform.c b/dll/3rdparty/libxslt/transform.c
index 4db703be405..639528de8e8 100644
--- a/dll/3rdparty/libxslt/transform.c
+++ b/dll/3rdparty/libxslt/transform.c
@@ -1860,7 +1860,7 @@ static void
 xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node,
                          xsltStackElemPtr params) {
     xmlNodePtr copy;
-    xmlNodePtr delete = NULL, cur;
+    xmlNodePtr cur;
     int nbchild = 0, oldSize;
     int childno = 0, oldPos;
     xsltTemplatePtr template;
@@ -1933,54 +1933,13 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, 
xmlNodePtr node,
            return;
     }
     /*
-     * Handling of Elements: first pass, cleanup and counting
+     * Handling of Elements: first pass, counting
      */
     cur = node->children;
     while (cur != NULL) {
-       switch (cur->type) {
-           case XML_TEXT_NODE:
-           case XML_CDATA_SECTION_NODE:
-           case XML_DOCUMENT_NODE:
-           case XML_HTML_DOCUMENT_NODE:
-           case XML_ELEMENT_NODE:
-           case XML_PI_NODE:
-           case XML_COMMENT_NODE:
-               nbchild++;
-               break;
-            case XML_DTD_NODE:
-               /* Unlink the DTD, it's still reachable using doc->intSubset */
-               if (cur->next != NULL)
-                   cur->next->prev = cur->prev;
-               if (cur->prev != NULL)
-                   cur->prev->next = cur->next;
-               break;
-           default:
-#ifdef WITH_XSLT_DEBUG_PROCESS
-               
XSLT_TRACE(ctxt,XSLT_TRACE_PROCESS_NODE,xsltGenericDebug(xsltGenericDebugContext,
-                "xsltDefaultProcessOneNode: skipping node type %d\n",
-                                cur->type));
-#endif
-               delete = cur;
-       }
+       if (IS_XSLT_REAL_NODE(cur))
+           nbchild++;
        cur = cur->next;
-       if (delete != NULL) {
-#ifdef WITH_XSLT_DEBUG_PROCESS
-           
XSLT_TRACE(ctxt,XSLT_TRACE_PROCESS_NODE,xsltGenericDebug(xsltGenericDebugContext,
-                "xsltDefaultProcessOneNode: removing ignorable blank node\n"));
-#endif
-           xmlUnlinkNode(delete);
-           xmlFreeNode(delete);
-           delete = NULL;
-       }
-    }
-    if (delete != NULL) {
-#ifdef WITH_XSLT_DEBUG_PROCESS
-       
XSLT_TRACE(ctxt,XSLT_TRACE_PROCESS_NODE,xsltGenericDebug(xsltGenericDebugContext,
-            "xsltDefaultProcessOneNode: removing ignorable blank node\n"));
-#endif
-       xmlUnlinkNode(delete);
-       xmlFreeNode(delete);
-       delete = NULL;
     }
 
     /*
@@ -3637,8 +3596,10 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, 
xmlNodePtr node,
     if (elements != NULL) {
        if (style->stripSpaces == NULL)
            style->stripSpaces = xmlHashCreate(10);
-       if (style->stripSpaces == NULL)
+       if (style->stripSpaces == NULL) {
+           xmlFree(elements);
            return;
+       }
 
        element = elements;
        while (*element != 0) {
@@ -4829,7 +4790,7 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, 
xmlNodePtr node,
     xsltStylePreCompPtr comp = (xsltStylePreCompPtr) castedComp;
 #endif
     int i;
-    xmlNodePtr cur, delNode = NULL, oldContextNode;
+    xmlNodePtr cur, oldContextNode;
     xmlNodeSetPtr list = NULL, oldList;
     xsltStackElemPtr withParams = NULL;
     int oldXPProximityPosition, oldXPContextSize;
@@ -4963,73 +4924,9 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, 
xmlNodePtr node,
        else
            cur = NULL;
        while (cur != NULL) {
-           switch (cur->type) {
-               case XML_TEXT_NODE:
-                   if ((IS_BLANK_NODE(cur)) &&
-                       (cur->parent != NULL) &&
-                       (cur->parent->type == XML_ELEMENT_NODE) &&
-                       (ctxt->style->stripSpaces != NULL)) {
-                       const xmlChar *val;
-
-                       if (cur->parent->ns != NULL) {
-                           val = (const xmlChar *)
-                                 xmlHashLookup2(ctxt->style->stripSpaces,
-                                                cur->parent->name,
-                                                cur->parent->ns->href);
-                           if (val == NULL) {
-                               val = (const xmlChar *)
-                                 xmlHashLookup2(ctxt->style->stripSpaces,
-                                                BAD_CAST "*",
-                                                cur->parent->ns->href);
-                           }
-                       } else {
-                           val = (const xmlChar *)
-                                 xmlHashLookup2(ctxt->style->stripSpaces,
-                                                cur->parent->name, NULL);
-                       }
-                       if ((val != NULL) &&
-                           (xmlStrEqual(val, (xmlChar *) "strip"))) {
-                           delNode = cur;
-                           break;
-                       }
-                   }
-                   /* Intentional fall-through */
-               case XML_ELEMENT_NODE:
-               case XML_DOCUMENT_NODE:
-               case XML_HTML_DOCUMENT_NODE:
-               case XML_CDATA_SECTION_NODE:
-               case XML_PI_NODE:
-               case XML_COMMENT_NODE:
-                   xmlXPathNodeSetAddUnique(list, cur);
-                   break;
-               case XML_DTD_NODE:
-                   /* Unlink the DTD, it's still reachable
-                    * using doc->intSubset */
-                   if (cur->next != NULL)
-                       cur->next->prev = cur->prev;
-                   if (cur->prev != NULL)
-                       cur->prev->next = cur->next;
-                   break;
-               case XML_NAMESPACE_DECL:
-                   break;
-               default:
-#ifdef WITH_XSLT_DEBUG_PROCESS
-                   
XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATES,xsltGenericDebug(xsltGenericDebugContext,
-                    "xsltApplyTemplates: skipping cur type %d\n",
-                                    cur->type));
-#endif
-                   delNode = cur;
-           }
+            if (IS_XSLT_REAL_NODE(cur))
+               xmlXPathNodeSetAddUnique(list, cur);
            cur = cur->next;
-           if (delNode != NULL) {
-#ifdef WITH_XSLT_DEBUG_PROCESS
-               
XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATES,xsltGenericDebug(xsltGenericDebugContext,
-                    "xsltApplyTemplates: removing ignorable blank cur\n"));
-#endif
-               xmlUnlinkNode(delNode);
-               xmlFreeNode(delNode);
-               delNode = NULL;
-           }
        }
     }
 
@@ -5086,6 +4983,7 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, 
xmlNodePtr node,
                xmlNodePtr sorts[XSLT_MAX_SORT];
 
                sorts[nbsorts++] = cur;
+               cur = cur->next;
 
                while (cur) {
 
diff --git a/dll/3rdparty/libxslt/xslt.c b/dll/3rdparty/libxslt/xslt.c
index 0c5eb2edcc0..a99f0d62867 100644
--- a/dll/3rdparty/libxslt/xslt.c
+++ b/dll/3rdparty/libxslt/xslt.c
@@ -3627,12 +3627,8 @@ xsltPreprocessStylesheet(xsltStylesheetPtr style, 
xmlNodePtr cur)
            (!xsltCheckExtURI(style, cur->ns->href))) {
            goto skip_children;
        } else if (cur->children != NULL) {
-           if ((cur->children->type != XML_ENTITY_DECL) &&
-               (cur->children->type != XML_ENTITY_REF_NODE) &&
-               (cur->children->type != XML_ENTITY_NODE)) {
-               cur = cur->children;
-               continue;
-           }
+           cur = cur->children;
+           continue;
        }
 
 skip_children:
diff --git a/dll/3rdparty/libxslt/xsltlocale.c 
b/dll/3rdparty/libxslt/xsltlocale.c
index 14b20edc21a..1a767809df9 100644
--- a/dll/3rdparty/libxslt/xsltlocale.c
+++ b/dll/3rdparty/libxslt/xsltlocale.c
@@ -341,7 +341,8 @@ xsltDefaultRegion(const xmlChar *localeName) {
 void
 xsltFreeLocale(xsltLocale locale) {
 #ifdef XSLT_LOCALE_POSIX
-    freelocale(locale);
+    if (locale != NULL)
+        freelocale(locale);
 #endif
 }
 
diff --git a/dll/3rdparty/libxslt/xsltutils.c b/dll/3rdparty/libxslt/xsltutils.c
index 865936ade42..9437ca9f55c 100644
--- a/dll/3rdparty/libxslt/xsltutils.c
+++ b/dll/3rdparty/libxslt/xsltutils.c
@@ -924,17 +924,19 @@ xsltDocumentSortFunction(xmlNodeSetPtr list) {
 }
 
 /**
- * xsltComputeSortResult:
+ * xsltComputeSortResultiInternal:
  * @ctxt:  a XSLT process context
  * @sort:  node list
+ * @xfrm:  Transform strings according to locale
  *
  * reorder the current node list accordingly to the set of sorting
  * requirement provided by the array of nodes.
  *
  * Returns a ordered XPath nodeset or NULL in case of error.
  */
-xmlXPathObjectPtr *
-xsltComputeSortResult(xsltTransformContextPtr ctxt, xmlNodePtr sort) {
+static xmlXPathObjectPtr *
+xsltComputeSortResultInternal(xsltTransformContextPtr ctxt, xmlNodePtr sort,
+                              int xfrm) {
 #ifdef XSLT_REFACTORED
     xsltStyleItemSortPtr comp;
 #else
@@ -1021,7 +1023,7 @@ xsltComputeSortResult(xsltTransformContextPtr ctxt, 
xmlNodePtr sort) {
                }
            } else {
                if (res->type == XPATH_STRING) {
-                   if (comp->locale != (xsltLocale)0) {
+                   if ((xfrm) && (comp->locale != (xsltLocale)0)) {
                        xmlChar *str = res->stringval;
                        res->stringval = (xmlChar *) xsltStrxfrm(comp->locale, 
str);
                        xmlFree(str);
@@ -1051,6 +1053,21 @@ xsltComputeSortResult(xsltTransformContextPtr ctxt, 
xmlNodePtr sort) {
     return(results);
 }
 
+/**
+ * xsltComputeSortResult:
+ * @ctxt:  a XSLT process context
+ * @sort:  node list
+ *
+ * reorder the current node list accordingly to the set of sorting
+ * requirement provided by the array of nodes.
+ *
+ * Returns a ordered XPath nodeset or NULL in case of error.
+ */
+xmlXPathObjectPtr *
+xsltComputeSortResult(xsltTransformContextPtr ctxt, xmlNodePtr sort) {
+    return xsltComputeSortResultInternal(ctxt, sort, /* xfrm */ 0);
+}
+
 /**
  * xsltDefaultSortFunction:
  * @ctxt:  a XSLT process context
@@ -1078,7 +1095,8 @@ xsltDefaultSortFunction(xsltTransformContextPtr ctxt, 
xmlNodePtr *sorts,
     int depth;
     xmlNodePtr node;
     xmlXPathObjectPtr tmp;
-    int tempstype[XSLT_MAX_SORT], temporder[XSLT_MAX_SORT];
+    int tempstype[XSLT_MAX_SORT], temporder[XSLT_MAX_SORT],
+        templang[XSLT_MAX_SORT];
 
     if ((ctxt == NULL) || (sorts == NULL) || (nbsorts <= 0) ||
        (nbsorts >= XSLT_MAX_SORT))
@@ -1100,7 +1118,7 @@ xsltDefaultSortFunction(xsltTransformContextPtr ctxt, 
xmlNodePtr *sorts,
            comp->stype =
                xsltEvalAttrValueTemplate(ctxt, sorts[j],
                                          (const xmlChar *) "data-type",
-                                         XSLT_NAMESPACE);
+                                         NULL);
            if (comp->stype != NULL) {
                tempstype[j] = 1;
                if (xmlStrEqual(comp->stype, (const xmlChar *) "text"))
@@ -1119,7 +1137,7 @@ xsltDefaultSortFunction(xsltTransformContextPtr ctxt, 
xmlNodePtr *sorts,
        if ((comp->order == NULL) && (comp->has_order != 0)) {
            comp->order = xsltEvalAttrValueTemplate(ctxt, sorts[j],
                                                    (const xmlChar *) "order",
-                                                   XSLT_NAMESPACE);
+                                                   NULL);
            if (comp->order != NULL) {
                temporder[j] = 1;
                if (xmlStrEqual(comp->order, (const xmlChar *) "ascending"))
@@ -1135,11 +1153,23 @@ xsltDefaultSortFunction(xsltTransformContextPtr ctxt, 
xmlNodePtr *sorts,
                }
            }
        }
+       templang[j] = 0;
+       if ((comp->lang == NULL) && (comp->has_lang != 0)) {
+            xmlChar *lang = xsltEvalAttrValueTemplate(ctxt, sorts[j],
+                                                     (xmlChar *) "lang",
+                                                     NULL);
+           if (lang != NULL) {
+               templang[j] = 1;
+                comp->locale = xsltNewLocale(lang);
+                xmlFree(lang);
+            }
+       }
     }
 
     len = list->nodeNr;
 
-    resultsTab[0] = xsltComputeSortResult(ctxt, sorts[0]);
+    resultsTab[0] = xsltComputeSortResultInternal(ctxt, sorts[0],
+                                                  /* xfrm */ 1);
     for (i = 1;i < XSLT_MAX_SORT;i++)
        resultsTab[i] = NULL;
 
@@ -1149,7 +1179,7 @@ xsltDefaultSortFunction(xsltTransformContextPtr ctxt, 
xmlNodePtr *sorts,
     descending = comp->descending;
     number = comp->number;
     if (results == NULL)
-       return;
+       goto cleanup;
 
     /* Shell's sort of node-set */
     for (incr = len / 2; incr > 0; incr /= 2) {
@@ -1210,8 +1240,10 @@ xsltDefaultSortFunction(xsltTransformContextPtr ctxt, 
xmlNodePtr *sorts,
                         * full set, this might be optimized ... or not
                         */
                        if (resultsTab[depth] == NULL)
-                           resultsTab[depth] = xsltComputeSortResult(ctxt,
-                                                       sorts[depth]);
+                           resultsTab[depth] =
+                                xsltComputeSortResultInternal(ctxt,
+                                                              sorts[depth],
+                                                              /* xfrm */ 1);
                        res = resultsTab[depth];
                        if (res == NULL)
                            break;
@@ -1291,6 +1323,7 @@ xsltDefaultSortFunction(xsltTransformContextPtr ctxt, 
xmlNodePtr *sorts,
        }
     }
 
+cleanup:
     for (j = 0; j < nbsorts; j++) {
        comp = sorts[j]->psvi;
        if (tempstype[j] == 1) {
@@ -1303,6 +1336,10 @@ xsltDefaultSortFunction(xsltTransformContextPtr ctxt, 
xmlNodePtr *sorts,
            xmlFree((void *)(comp->order));
            comp->order = NULL;
        }
+       if (templang[j] == 1) {
+           xsltFreeLocale(comp->locale);
+           comp->locale = (xsltLocale)0;
+       }
        if (resultsTab[j] != NULL) {
            for (i = 0;i < len;i++)
                xmlXPathFreeObject(resultsTab[j][i]);
diff --git a/dll/3rdparty/libxslt/xsltwin32config.h 
b/dll/3rdparty/libxslt/xsltwin32config.h
index 8085bc2fa82..db760c5edd5 100644
--- a/dll/3rdparty/libxslt/xsltwin32config.h
+++ b/dll/3rdparty/libxslt/xsltwin32config.h
@@ -23,21 +23,21 @@ extern "C" {
  *
  * the version string like "1.2.3"
  */
-#define LIBXSLT_DOTTED_VERSION "1.1.34"
+#define LIBXSLT_DOTTED_VERSION "1.1.35"
 
 /**
  * LIBXSLT_VERSION:
  *
  * the version number: 1.2.3 value is 1002003
  */
-#define LIBXSLT_VERSION 10134
+#define LIBXSLT_VERSION 10135
 
 /**
  * LIBXSLT_VERSION_STRING:
  *
  * the version number string, 1.2.3 value is "1002003"
  */
-#define LIBXSLT_VERSION_STRING "10134"
+#define LIBXSLT_VERSION_STRING "10135"
 
 /**
  * LIBXSLT_VERSION_EXTRA:
diff --git a/media/doc/3rd Party Files.txt b/media/doc/3rd Party Files.txt
index 16917402132..9a6fa15fcfb 100644
--- a/media/doc/3rd Party Files.txt     
+++ b/media/doc/3rd Party Files.txt     
@@ -45,7 +45,7 @@ URL: http://www.simplesystems.org/libtiff/
 
 Title: Libxslt
 Path: dll/3rdparty/libxslt
-Used Version: 1.1.34
+Used Version: 1.1.35
 License: MIT (https://spdx.org/licenses/MIT.html)
 URL: http://xmlsoft.org
 
diff --git a/sdk/include/reactos/libs/libxslt/extensions.h 
b/sdk/include/reactos/libs/libxslt/extensions.h
index 900779c34c0..84d6aa44ad3 100644
--- a/sdk/include/reactos/libs/libxslt/extensions.h
+++ b/sdk/include/reactos/libs/libxslt/extensions.h
@@ -246,7 +246,7 @@ XSLTPUBFUN xmlHashTablePtr XSLTCALL
                                         const xmlChar *URI);
 
 /**
- * Test module http://xmlsoft.org/XSLT/
+ * Test of the extension module API
  */
 XSLTPUBFUN void XSLTCALL
                xsltRegisterTestModule  (void);
diff --git a/sdk/include/reactos/libs/libxslt/xsltInternals.h 
b/sdk/include/reactos/libs/libxslt/xsltInternals.h
index 14a971aaa30..14343d2751c 100644
--- a/sdk/include/reactos/libs/libxslt/xsltInternals.h
+++ b/sdk/include/reactos/libs/libxslt/xsltInternals.h
@@ -291,6 +291,9 @@ struct _xsltTemplate {
     int              templMax;         /* Size of the templtes stack */
     xsltTemplatePtr *templCalledTab;   /* templates called */
     int             *templCountTab;  /* .. and how often */
+
+    /* Conflict resolution */
+    int position;
 };
 
 /**
@@ -1500,17 +1503,18 @@ struct _xsltStylesheet {
     /*
      * Template descriptions.
      */
-    xsltTemplatePtr templates; /* the ordered list of templates */
-    void *templatesHash;       /* hash table or wherever compiled templates
-                                  information is stored */
-    void *rootMatch;           /* template based on / */
-    void *keyMatch;            /* template based on key() */
-    void *elemMatch;           /* template based on * */
-    void *attrMatch;           /* template based on @* */
-    void *parentMatch;         /* template based on .. */
-    void *textMatch;           /* template based on text() */
-    void *piMatch;             /* template based on processing-instruction() */
-    void *commentMatch;                /* template based on comment() */
+    xsltTemplatePtr templates;           /* the ordered list of templates */
+    xmlHashTablePtr templatesHash;       /* hash table or wherever compiled
+                                            templates information is stored */
+    struct _xsltCompMatch *rootMatch;    /* template based on / */
+    struct _xsltCompMatch *keyMatch;     /* template based on key() */
+    struct _xsltCompMatch *elemMatch;    /* template based on * */
+    struct _xsltCompMatch *attrMatch;    /* template based on @* */
+    struct _xsltCompMatch *parentMatch;  /* template based on .. */
+    struct _xsltCompMatch *textMatch;    /* template based on text() */
+    struct _xsltCompMatch *piMatch;      /* template based on
+                                            processing-instruction() */
+    struct _xsltCompMatch *commentMatch; /* template based on comment() */
 
     /*
      * Namespace aliases.
diff --git a/sdk/include/reactos/libs/libxslt/xsltconfig.h 
b/sdk/include/reactos/libs/libxslt/xsltconfig.h
index 5d6f73f0402..f7a2a8e988f 100644
--- a/sdk/include/reactos/libs/libxslt/xsltconfig.h
+++ b/sdk/include/reactos/libs/libxslt/xsltconfig.h
@@ -20,21 +20,21 @@ extern "C" {
  *
  * the version string like "1.2.3"
  */
-#define LIBXSLT_DOTTED_VERSION "1.1.34"
+#define LIBXSLT_DOTTED_VERSION "1.1.35"
 
 /**
  * LIBXSLT_VERSION:
  *
  * the version number: 1.2.3 value is 10203
  */
-#define LIBXSLT_VERSION 10134
+#define LIBXSLT_VERSION 10135
 
 /**
  * LIBXSLT_VERSION_STRING:
  *
  * the version number string, 1.2.3 value is "10203"
  */
-#define LIBXSLT_VERSION_STRING "10134"
+#define LIBXSLT_VERSION_STRING "10135"
 
 /**
  * LIBXSLT_VERSION_EXTRA:

Reply via email to