# HG changeset patch # User Nick Wellnhofer <wellnhofer@aevum.de> # Date 1623855583 -7200 # Wed Jun 16 16:59:43 2021 +0200 # Node ID c3f6bb69ca5bfdeeefc8f28e85603764c437d4a5 # Parent 769e915c79f1f6deed4c070b39bc423514215cb9 Fix regression in xsltComputeSortResult After implementing locale support, xsltComputeSortResult returned strings transformed with strxfrm. This confused external users of this function, mainly WebKit derived browsers implementing their own sort function, similar to examples/xsltICUSort.c. Revert to the old behavior for external callers. diff --git a/libxslt/xsltutils.c b/libxslt/xsltutils.c --- a/libxslt/xsltutils.c +++ b/libxslt/xsltutils.c @@ -948,17 +948,19 @@ } /** - * 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 @@ -1045,7 +1047,7 @@ } } 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); @@ -1076,6 +1078,21 @@ } /** + * 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 * @sorts: array of sort nodes @@ -1175,7 +1192,8 @@ 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; @@ -1246,8 +1264,10 @@ * 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;