commit: 8b5c0d83b88e109650baeeb1f31068205196a8e9 Author: Sam James <sam <AT> gentoo <DOT> org> AuthorDate: Thu Jul 4 00:23:57 2024 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Thu Jul 4 00:28:12 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8b5c0d83
dev-libs/libxslt: add 1.1.41 I did backport patches to help work with older libxml2 but the tests don't build (implicit func decls) and then I saw Nick mention in a bug [0] that 2.13 is required to fix all known problems anyway, so let's require that (sorry). [0] https://gitlab.gnome.org/GNOME/libxslt/-/issues/116#note_2155804 Closes: https://bugs.gentoo.org/935151 Signed-off-by: Sam James <sam <AT> gentoo.org> dev-libs/libxslt/Manifest | 1 + ...-1.1.41-deprecated-xmlCharEncodingHandler.patch | 93 +++++++++++ ...extensions-xmlCheckFilename-older-libxml2.patch | 40 +++++ .../files/libxslt-1.1.41-libxml2-2.13.patch | 171 +++++++++++++++++++++ .../{libxslt-9999.ebuild => libxslt-1.1.41.ebuild} | 15 +- dev-libs/libxslt/libxslt-9999.ebuild | 15 +- 6 files changed, 329 insertions(+), 6 deletions(-) diff --git a/dev-libs/libxslt/Manifest b/dev-libs/libxslt/Manifest index 0c049556676a..b10e3d3f68d3 100644 --- a/dev-libs/libxslt/Manifest +++ b/dev-libs/libxslt/Manifest @@ -1 +1,2 @@ DIST libxslt-1.1.39.tar.xz 1578216 BLAKE2B 7c87b769d345fc99a966bea6b4e94533fa211dc3a987ce013a03eefb05dde73ef75526bdecf7d32d8c77112232096fb22d8ec4f0a781b9f59d0422a2db75df01 SHA512 c0c99dc63f8b2acb6cc3ad7ad684ffa2a427ee8d1740495cbf8a7c9b9c8679f96351b4b676c73ccc191014db4cb4ab42b9a0070f6295565f39dbc665c5c16f89 +DIST libxslt-1.1.41.tar.xz 1573868 BLAKE2B 2228a4074f257edd4fa0ebb2a713b035b780b19398ba9208dedb0d0cec6777129c9bb08a80494b657a4238bea228bd752761118a0022f56d71cc1302838b1733 SHA512 b9f94d1c00dfb9f731c6c424a0d3f07fb0a37935048b26618e5405c3890d1d40c832420117de4d5363a90ab4809f77f6e566013ce7858cc88e0905709ca0f6fe diff --git a/dev-libs/libxslt/files/libxslt-1.1.41-deprecated-xmlCharEncodingHandler.patch b/dev-libs/libxslt/files/libxslt-1.1.41-deprecated-xmlCharEncodingHandler.patch new file mode 100644 index 000000000000..86c779c3c7cf --- /dev/null +++ b/dev-libs/libxslt/files/libxslt-1.1.41-deprecated-xmlCharEncodingHandler.patch @@ -0,0 +1,93 @@ +https://gitlab.gnome.org/GNOME/libxslt/-/commit/8d456f03b6b6661edfb0a3f1bc5abdc9597f60e7 + +From 8d456f03b6b6661edfb0a3f1bc5abdc9597f60e7 Mon Sep 17 00:00:00 2001 +From: Nick Wellnhofer <wellnho...@aevum.de> +Date: Tue, 2 Jul 2024 22:27:02 +0200 +Subject: [PATCH] utils: Don't use deprecated xmlCharEncodingHandler member + +--- + libxslt/xsltutils.c | 44 ++++++++++++++++++++------------------------ + 1 file changed, 20 insertions(+), 24 deletions(-) + +diff --git a/libxslt/xsltutils.c b/libxslt/xsltutils.c +index 3705d28f..d493905b 100644 +--- a/libxslt/xsltutils.c ++++ b/libxslt/xsltutils.c +@@ -1750,13 +1750,12 @@ xsltSaveResultToFilename(const char *URL, xmlDocPtr result, + + XSLT_GET_IMPORT_PTR(encoding, style, encoding) + if (encoding != NULL) { +- xmlCharEncodingHandlerPtr encoder; ++ xmlCharEncodingHandlerPtr encoder = NULL; + +- encoder = xmlFindCharEncodingHandler((char *)encoding); +- if ((encoder != NULL) && +- (xmlStrEqual((const xmlChar *)encoder->name, +- (const xmlChar *) "UTF-8"))) +- encoder = NULL; ++ /* Don't use UTF-8 dummy encoder */ ++ if ((xmlStrcasecmp(encoding, BAD_CAST "UTF-8") != 0) && ++ (xmlStrcasecmp(encoding, BAD_CAST "UTF8") != 0)) ++ encoder = xmlFindCharEncodingHandler((char *) encoding); + buf = xmlOutputBufferCreateFilename(URL, encoder, compression); + } else { + buf = xmlOutputBufferCreateFilename(URL, NULL, compression); +@@ -1793,13 +1792,12 @@ xsltSaveResultToFile(FILE *file, xmlDocPtr result, xsltStylesheetPtr style) { + + XSLT_GET_IMPORT_PTR(encoding, style, encoding) + if (encoding != NULL) { +- xmlCharEncodingHandlerPtr encoder; ++ xmlCharEncodingHandlerPtr encoder = NULL; + +- encoder = xmlFindCharEncodingHandler((char *)encoding); +- if ((encoder != NULL) && +- (xmlStrEqual((const xmlChar *)encoder->name, +- (const xmlChar *) "UTF-8"))) +- encoder = NULL; ++ /* Don't use UTF-8 dummy encoder */ ++ if ((xmlStrcasecmp(encoding, BAD_CAST "UTF-8") != 0) && ++ (xmlStrcasecmp(encoding, BAD_CAST "UTF8") != 0)) ++ encoder = xmlFindCharEncodingHandler((char *) encoding); + buf = xmlOutputBufferCreateFile(file, encoder); + } else { + buf = xmlOutputBufferCreateFile(file, NULL); +@@ -1837,13 +1835,12 @@ xsltSaveResultToFd(int fd, xmlDocPtr result, xsltStylesheetPtr style) { + + XSLT_GET_IMPORT_PTR(encoding, style, encoding) + if (encoding != NULL) { +- xmlCharEncodingHandlerPtr encoder; ++ xmlCharEncodingHandlerPtr encoder = NULL; + +- encoder = xmlFindCharEncodingHandler((char *)encoding); +- if ((encoder != NULL) && +- (xmlStrEqual((const xmlChar *)encoder->name, +- (const xmlChar *) "UTF-8"))) +- encoder = NULL; ++ /* Don't use UTF-8 dummy encoder */ ++ if ((xmlStrcasecmp(encoding, BAD_CAST "UTF-8") != 0) && ++ (xmlStrcasecmp(encoding, BAD_CAST "UTF8") != 0)) ++ encoder = xmlFindCharEncodingHandler((char *) encoding); + buf = xmlOutputBufferCreateFd(fd, encoder); + } else { + buf = xmlOutputBufferCreateFd(fd, NULL); +@@ -1880,13 +1877,12 @@ xsltSaveResultToString(xmlChar **doc_txt_ptr, int * doc_txt_len, + + XSLT_GET_IMPORT_PTR(encoding, style, encoding) + if (encoding != NULL) { +- xmlCharEncodingHandlerPtr encoder; ++ xmlCharEncodingHandlerPtr encoder = NULL; + +- encoder = xmlFindCharEncodingHandler((char *)encoding); +- if ((encoder != NULL) && +- (xmlStrEqual((const xmlChar *)encoder->name, +- (const xmlChar *) "UTF-8"))) +- encoder = NULL; ++ /* Don't use UTF-8 dummy encoder */ ++ if ((xmlStrcasecmp(encoding, BAD_CAST "UTF-8") != 0) && ++ (xmlStrcasecmp(encoding, BAD_CAST "UTF8") != 0)) ++ encoder = xmlFindCharEncodingHandler((char *) encoding); + buf = xmlAllocOutputBuffer(encoder); + if (buf == NULL) + xmlCharEncCloseFunc(encoder); +-- +GitLab diff --git a/dev-libs/libxslt/files/libxslt-1.1.41-extensions-xmlCheckFilename-older-libxml2.patch b/dev-libs/libxslt/files/libxslt-1.1.41-extensions-xmlCheckFilename-older-libxml2.patch new file mode 100644 index 000000000000..bdf39460af2a --- /dev/null +++ b/dev-libs/libxslt/files/libxslt-1.1.41-extensions-xmlCheckFilename-older-libxml2.patch @@ -0,0 +1,40 @@ +https://gitlab.gnome.org/GNOME/libxslt/-/commit/a85bd17ec52793b33074f0f785c3d989feb20170 + +From a85bd17ec52793b33074f0f785c3d989feb20170 Mon Sep 17 00:00:00 2001 +From: Nick Wellnhofer <wellnho...@aevum.de> +Date: Fri, 21 Jun 2024 15:07:18 +0200 +Subject: [PATCH] extensions: Readd call to xmlCheckFilename with older libxml2 + +Fix spurious warning with libxml2 before 2.13.0 caused by 014b2892. + +Fixes #113. +--- + libxslt/extensions.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/libxslt/extensions.c b/libxslt/extensions.c +index 05cdf354..d3d61543 100644 +--- a/libxslt/extensions.c ++++ b/libxslt/extensions.c +@@ -415,6 +415,19 @@ xsltExtModuleRegisterDynamic(const xmlChar * URI) + module_filename, URI); + #endif + ++#if LIBXML_VERSION < 21300 ++ if (1 != xmlCheckFilename(module_filename)) { ++ ++#ifdef WITH_XSLT_DEBUG_EXTENSIONS ++ xsltGenericDebug(xsltGenericDebugContext, ++ "xmlCheckFilename failed for plugin: %s\n", module_filename); ++#endif ++ ++ xmlFree(ext_name); ++ return (-1); ++ } ++#endif ++ + /* attempt to open the module */ + m = xmlModuleOpen(module_filename, 0); + if (NULL == m) { +-- +GitLab diff --git a/dev-libs/libxslt/files/libxslt-1.1.41-libxml2-2.13.patch b/dev-libs/libxslt/files/libxslt-1.1.41-libxml2-2.13.patch new file mode 100644 index 000000000000..99b89ae08f74 --- /dev/null +++ b/dev-libs/libxslt/files/libxslt-1.1.41-libxml2-2.13.patch @@ -0,0 +1,171 @@ +https://gitlab.gnome.org/GNOME/libxslt/-/issues/116 +https://gitlab.gnome.org/GNOME/libxslt/-/commit/081cd6e97a620d035ed7df35e998e2d288bc7862 + +From 081cd6e97a620d035ed7df35e998e2d288bc7862 Mon Sep 17 00:00:00 2001 +From: Nick Wellnhofer <wellnho...@aevum.de> +Date: Mon, 1 Jul 2024 13:21:14 +0200 +Subject: [PATCH] transform: Handle filesystem paths after libxml2 changes + +After changes in libxml2 2.13, base URIs and resolved URIs can be +filesystem paths. + +Check for invalid URIs and remove fragment before resolving URI in +xsltDocumentFunction. + +Handle filesystem paths in xsltCheckRead. + +Should fix #116. +--- + libxslt/functions.c | 64 ++++++++++++++++++++++++++------------------- + libxslt/security.c | 13 +++++++++ + 2 files changed, 50 insertions(+), 27 deletions(-) + +diff --git a/libxslt/functions.c b/libxslt/functions.c +index 0c9dec43..d54f8f48 100644 +--- a/libxslt/functions.c ++++ b/libxslt/functions.c +@@ -96,11 +96,10 @@ xsltXPathFunctionLookup (void *vctxt, + ************************************************************************/ + + static void +-xsltDocumentFunctionLoadDocument(xmlXPathParserContextPtr ctxt, xmlChar* URI) ++xsltDocumentFunctionLoadDocument(xmlXPathParserContextPtr ctxt, ++ const xmlChar* URI, const xmlChar *fragment) + { + xsltTransformContextPtr tctxt; +- xmlURIPtr uri; +- xmlChar *fragment = NULL; + xsltDocumentPtr idoc; /* document info */ + xmlDocPtr doc; + xmlXPathContextPtr xptrctxt = NULL; +@@ -115,26 +114,7 @@ xsltDocumentFunctionLoadDocument(xmlXPathParserContextPtr ctxt, xmlChar* URI) + goto out_fragment; + } + +- uri = xmlParseURI((const char *) URI); +- if (uri == NULL) { +- xsltTransformError(tctxt, NULL, NULL, +- "document() : failed to parse URI\n"); +- goto out_fragment; +- } +- +- /* +- * check for and remove fragment identifier +- */ +- fragment = (xmlChar *)uri->fragment; +- if (fragment != NULL) { +- xmlChar *newURI; +- uri->fragment = NULL; +- newURI = xmlSaveUri(uri); +- idoc = xsltLoadDocument(tctxt, newURI); +- xmlFree(newURI); +- } else +- idoc = xsltLoadDocument(tctxt, URI); +- xmlFreeURI(uri); ++ idoc = xsltLoadDocument(tctxt, URI); + + if (idoc == NULL) { + if ((URI == NULL) || +@@ -194,7 +174,6 @@ out_fragment: + if (resObj == NULL) + resObj = xmlXPathNewNodeSet(NULL); + valuePush(ctxt, resObj); +- xmlFree(fragment); + } + + /** +@@ -210,7 +189,8 @@ xsltDocumentFunction(xmlXPathParserContextPtr ctxt, int nargs) + { + xmlXPathObjectPtr obj, obj2 = NULL; + xmlChar *base = NULL, *URI; +- ++ xmlChar *newURI = NULL; ++ xmlChar *fragment = NULL; + + if ((nargs < 1) || (nargs > 2)) { + xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL, +@@ -292,7 +272,32 @@ xsltDocumentFunction(xmlXPathParserContextPtr ctxt, int nargs) + valuePush(ctxt, xmlXPathNewNodeSet(NULL)); + } else { + xsltTransformContextPtr tctxt; ++ xmlURIPtr uri; ++ const xmlChar *url; ++ + tctxt = xsltXPathGetTransformContext(ctxt); ++ ++ url = obj->stringval; ++ ++ uri = xmlParseURI((const char *) url); ++ if (uri == NULL) { ++ xsltTransformError(tctxt, NULL, NULL, ++ "document() : failed to parse URI '%s'\n", url); ++ valuePush(ctxt, xmlXPathNewNodeSet(NULL)); ++ goto error; ++ } ++ ++ /* ++ * check for and remove fragment identifier ++ */ ++ fragment = (xmlChar *)uri->fragment; ++ if (fragment != NULL) { ++ uri->fragment = NULL; ++ newURI = xmlSaveUri(uri); ++ url = newURI; ++ } ++ xmlFreeURI(uri); ++ + if ((obj2 != NULL) && (obj2->nodesetval != NULL) && + (obj2->nodesetval->nodeNr > 0) && + IS_XSLT_REAL_NODE(obj2->nodesetval->nodeTab[0])) { +@@ -313,7 +318,8 @@ xsltDocumentFunction(xmlXPathParserContextPtr ctxt, int nargs) + (xmlNodePtr) tctxt->style->doc); + } + } +- URI = xmlBuildURI(obj->stringval, base); ++ ++ URI = xmlBuildURI(url, base); + if (base != NULL) + xmlFree(base); + if (URI == NULL) { +@@ -326,10 +332,14 @@ xsltDocumentFunction(xmlXPathParserContextPtr ctxt, int nargs) + valuePush(ctxt, xmlXPathNewNodeSet(NULL)); + } + } else { +- xsltDocumentFunctionLoadDocument( ctxt, URI ); ++ xsltDocumentFunctionLoadDocument(ctxt, URI, fragment); + xmlFree(URI); + } + } ++ ++error: ++ xmlFree(newURI); ++ xmlFree(fragment); + xmlXPathFreeObject(obj); + if (obj2 != NULL) + xmlXPathFreeObject(obj2); +diff --git a/libxslt/security.c b/libxslt/security.c +index 001ee6e4..3a66594f 100644 +--- a/libxslt/security.c ++++ b/libxslt/security.c +@@ -422,6 +422,19 @@ xsltCheckRead(xsltSecurityPrefsPtr sec, + xmlURIPtr uri; + xsltSecurityCheck check; + ++ if (xmlStrstr(URL, BAD_CAST "://") == NULL) { ++ check = xsltGetSecurityPrefs(sec, XSLT_SECPREF_READ_FILE); ++ if (check != NULL) { ++ ret = check(sec, ctxt, (const char *) URL); ++ if (ret == 0) { ++ xsltTransformError(ctxt, NULL, NULL, ++ "Local file read for %s refused\n", URL); ++ return(0); ++ } ++ } ++ return(1); ++ } ++ + uri = xmlParseURI((const char *)URL); + if (uri == NULL) { + xsltTransformError(ctxt, NULL, NULL, +-- +GitLab diff --git a/dev-libs/libxslt/libxslt-9999.ebuild b/dev-libs/libxslt/libxslt-1.1.41.ebuild similarity index 87% copy from dev-libs/libxslt/libxslt-9999.ebuild copy to dev-libs/libxslt/libxslt-1.1.41.ebuild index 22acdc53723a..57f23538af3d 100644 --- a/dev-libs/libxslt/libxslt-9999.ebuild +++ b/dev-libs/libxslt/libxslt-1.1.41.ebuild @@ -25,9 +25,12 @@ REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" BDEPEND=">=virtual/pkgconfig-1" RDEPEND=" - >=dev-libs/libxml2-2.9.11:2[${MULTILIB_USEDEP}] - crypt? ( >=dev-libs/libgcrypt-1.5.3:0=[${MULTILIB_USEDEP}] ) - python? ( ${PYTHON_DEPS} ) + >=dev-libs/libxml2-2.13:2[${MULTILIB_USEDEP}] + crypt? ( >=dev-libs/libgcrypt-1.5.3:=[${MULTILIB_USEDEP}] ) + python? ( + ${PYTHON_DEPS} + >=dev-libs/libxml2-2.13:2[${MULTILIB_USEDEP},python,${PYTHON_USEDEP}] + ) " DEPEND="${RDEPEND}" @@ -39,6 +42,12 @@ MULTILIB_WRAPPED_HEADERS=( /usr/include/libxslt/xsltconfig.h ) +PATCHES=( + "${FILESDIR}"/${P}-extensions-xmlCheckFilename-older-libxml2.patch + "${FILESDIR}"/${P}-libxml2-2.13.patch + "${FILESDIR}"/${P}-deprecated-xmlCharEncodingHandler.patch +) + src_prepare() { default diff --git a/dev-libs/libxslt/libxslt-9999.ebuild b/dev-libs/libxslt/libxslt-9999.ebuild index 22acdc53723a..57f23538af3d 100644 --- a/dev-libs/libxslt/libxslt-9999.ebuild +++ b/dev-libs/libxslt/libxslt-9999.ebuild @@ -25,9 +25,12 @@ REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" BDEPEND=">=virtual/pkgconfig-1" RDEPEND=" - >=dev-libs/libxml2-2.9.11:2[${MULTILIB_USEDEP}] - crypt? ( >=dev-libs/libgcrypt-1.5.3:0=[${MULTILIB_USEDEP}] ) - python? ( ${PYTHON_DEPS} ) + >=dev-libs/libxml2-2.13:2[${MULTILIB_USEDEP}] + crypt? ( >=dev-libs/libgcrypt-1.5.3:=[${MULTILIB_USEDEP}] ) + python? ( + ${PYTHON_DEPS} + >=dev-libs/libxml2-2.13:2[${MULTILIB_USEDEP},python,${PYTHON_USEDEP}] + ) " DEPEND="${RDEPEND}" @@ -39,6 +42,12 @@ MULTILIB_WRAPPED_HEADERS=( /usr/include/libxslt/xsltconfig.h ) +PATCHES=( + "${FILESDIR}"/${P}-extensions-xmlCheckFilename-older-libxml2.patch + "${FILESDIR}"/${P}-libxml2-2.13.patch + "${FILESDIR}"/${P}-deprecated-xmlCharEncodingHandler.patch +) + src_prepare() { default