Date: Tuesday, May 5, 2020 @ 10:33:49 Author: jgc Revision: 382285 Add debian patch local (FS#66520)
Added: libxslt/trunk/0002-Make-generate-id-deterministic.patch Modified: libxslt/trunk/PKGBUILD -------------------------------------------+ 0002-Make-generate-id-deterministic.patch | 180 ++++++++++++++++++++++++++++ PKGBUILD | 2 2 files changed, 181 insertions(+), 1 deletion(-) Added: 0002-Make-generate-id-deterministic.patch =================================================================== --- 0002-Make-generate-id-deterministic.patch (rev 0) +++ 0002-Make-generate-id-deterministic.patch 2020-05-05 10:33:49 UTC (rev 382285) @@ -0,0 +1,180 @@ +From: Daniel Veillard <veill...@redhat.com> +Date: Sun, 29 Oct 2017 01:04:54 +0200 +Subject: Make generate-id deterministic + +Origin: upstream, https://bugzilla.gnome.org/attachment.cgi?id=306475 +Bug: https://bugzilla.gnome.org/show_bug.cgi?id=751621 +Bug-Debian: https://bugs.debian.org/823857 +--- + libxslt/functions.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++- + libxslt/functions.h | 7 ++++ + libxslt/transform.c | 8 +++++ + libxslt/xsltInternals.h | 2 ++ + 4 files changed, 107 insertions(+), 1 deletion(-) + +diff --git a/libxslt/functions.c b/libxslt/functions.c +index b350545..858a483 100644 +--- a/libxslt/functions.c ++++ b/libxslt/functions.c +@@ -671,6 +671,63 @@ xsltFormatNumberFunction(xmlXPathParserContextPtr ctxt, int nargs) + xmlXPathFreeObject(decimalObj); + } + ++/** ++ * xsltCleanupIds: ++ * @ctxt: the transformation context ++ * @root: the root of the resulting document ++ * ++ * This clean up ids which may have been saved in Element contents ++ * by xsltGenerateIdFunction() to provide stable IDs on elements. ++ * ++ * Returns the number of items cleaned or -1 in case of error ++ */ ++int ++xsltCleanupIds(xsltTransformContextPtr ctxt, xmlNodePtr root) { ++ xmlNodePtr cur; ++ int count = 0; ++ ++ if ((ctxt == NULL) || (root == NULL)) ++ return(-1); ++ if (root->type != XML_ELEMENT_NODE) ++ return(-1); ++ ++ cur = root; ++ while (cur != NULL) { ++ if (cur->type == XML_ELEMENT_NODE) { ++ if (cur->content != NULL) { ++ cur->content = NULL; ++ count++; ++ } ++ if (cur->children != NULL) { ++ cur = cur->children; ++ continue; ++ } ++ } ++ if (cur->next != NULL) { ++ cur = cur->next; ++ continue; ++ } ++ do { ++ cur = cur->parent; ++ if (cur == NULL) ++ break; ++ if (cur == (xmlNodePtr) root) { ++ cur = NULL; ++ break; ++ } ++ if (cur->next != NULL) { ++ cur = cur->next; ++ break; ++ } ++ } while (cur != NULL); ++ } ++ ++fprintf(stderr, "Attributed %d IDs for element, cleaned up %d\n", ++ ctxt->nextid, count); ++ ++ return(count); ++} ++ + /** + * xsltGenerateIdFunction: + * @ctxt: the XPath Parser context +@@ -722,7 +779,39 @@ xsltGenerateIdFunction(xmlXPathParserContextPtr ctxt, int nargs){ + if (obj) + xmlXPathFreeObject(obj); + +- val = (long)((char *)cur - (char *)&base_address); ++ /* ++ * Try to provide stable ID for generated document: ++ * - usually ID are computed to be placed on elements via attributes ++ * so using the element as the node for the ID ++ * - the cur->content should be a correct placeholder for this, we use ++ * it to hold element node numbers in xmlXPathOrderDocElems to ++ * speed up XPath too ++ * - xsltCleanupIds() clean them up before handing the XSLT output ++ * to the API client. ++ * - other nodes types use the node address method but that should ++ * not end up in resulting document ID ++ * - we can enable this by default without risk of performance issues ++ * only the one pass xsltCleanupIds() is added ++ */ ++ if (cur->type == XML_ELEMENT_NODE) { ++ if (cur->content == NULL) { ++ xsltTransformContextPtr tctxt; ++ ++ tctxt = xsltXPathGetTransformContext(ctxt); ++ if (tctxt == NULL) { ++ val = (long)((char *)cur - (char *)&base_address); ++ } else { ++ tctxt->nextid++; ++ val = tctxt->nextid; ++ cur->content = (void *) (val); ++ } ++ } else { ++ val = (long) cur->content; ++ } ++ } else { ++ val = (long)((char *)cur - (char *)&base_address); ++ } ++ + if (val >= 0) { + snprintf((char *)str, sizeof(str), "idp%ld", val); + } else { +diff --git a/libxslt/functions.h b/libxslt/functions.h +index 5455b7f..3116361 100644 +--- a/libxslt/functions.h ++++ b/libxslt/functions.h +@@ -63,6 +63,13 @@ XSLTPUBFUN void XSLTCALL + xsltFunctionAvailableFunction (xmlXPathParserContextPtr ctxt, + int nargs); + ++/* ++ * Cleanup for ID generation ++ */ ++XSLTPUBFUN int XSLTCALL ++ xsltCleanupIds (xsltTransformContextPtr ctxt, ++ xmlNodePtr root); ++ + /* + * And the registration + */ +diff --git a/libxslt/transform.c b/libxslt/transform.c +index d1c4793..3d1ee05 100644 +--- a/libxslt/transform.c ++++ b/libxslt/transform.c +@@ -706,6 +706,7 @@ xsltNewTransformContext(xsltStylesheetPtr style, xmlDocPtr doc) { + cur->traceCode = (unsigned long*) &xsltDefaultTrace; + cur->xinclude = xsltGetXIncludeDefault(); + cur->keyInitLevel = 0; ++ cur->nextid = 0; + + return(cur); + +@@ -6140,6 +6141,13 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc, + if (root != NULL) { + const xmlChar *doctype = NULL; + ++ /* ++ * cleanup ids which may have been saved in Elements content ptrs ++ */ ++ if (ctxt->nextid != 0) { ++ xsltCleanupIds(ctxt, root); ++ } ++ + if ((root->ns != NULL) && (root->ns->prefix != NULL)) + doctype = xmlDictQLookup(ctxt->dict, root->ns->prefix, root->name); + if (doctype == NULL) +diff --git a/libxslt/xsltInternals.h b/libxslt/xsltInternals.h +index 14a971a..a7d71b5 100644 +--- a/libxslt/xsltInternals.h ++++ b/libxslt/xsltInternals.h +@@ -1782,6 +1782,8 @@ struct _xsltTransformContext { + int maxTemplateVars; + unsigned long opLimit; + unsigned long opCount; ++ ++ unsigned long nextid;/* for generating stable ids */ + }; + + /** Modified: PKGBUILD =================================================================== --- PKGBUILD 2020-05-05 10:33:02 UTC (rev 382284) +++ PKGBUILD 2020-05-05 10:33:49 UTC (rev 382285) @@ -13,7 +13,7 @@ checkdepends=(docbook-xml python) _commit=3653123f992db24cec417d12600f4c67388025e3 # tags/v1.1.34^0 source=("git+https://gitlab.gnome.org/GNOME/libxslt.git#commit=$_commit" - https://sources.debian.org/data/main/libx/libxslt/1.1.34-1/debian/patches/0002-Make-generate-id-deterministic.patch) + 0002-Make-generate-id-deterministic.patch) sha256sums=('SKIP' '371f8a27e57f648315d2ef73499e9bdc15bc3d83956c63b98eb6865f18411b62')