From: David Stacey <drstacey@tiscali.co.uk>
To: cygwin@cygwin.com
Cc: kay_ulbrich@web.de
Subject: libxml2: Attribute decoding patch (was: Re: xmlstarlet ignores XML attributes)
Date: Mon, 02 Oct 2017 19:10:00 -0000 [thread overview]
Message-ID: <f6f71329-0582-985d-3dd2-ecb9191687bb@tiscali.co.uk> (raw)
In-Reply-To: <a26314fa-e463-113b-b8b3-df353a620cb0@web.de>
[-- Attachment #1: Type: text/plain, Size: 647 bytes --]
On 30/09/2017 16:25, Kay Ulbrich wrote:
> on a current Cygwin-installation, xmlstarlet fails to validate a valid
> XML document against an XML schema (XSD).
>
> [snip]
>
> I found a quite recent similar bug report for Debian, there seems to be
> a problem with certain versions of libxml:
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=832602
Yaakov, please could you consider taking the patch attached, which is
from Debian Stretch [1]. Or you may prefer to update to libxml2-2.9.5,
as the patch has been incorporated upstream. Either should address the
problem reported above.
Dave.
[1] - https://packages.debian.org/stretch/libxml2
[-- Attachment #2: 0008-Fix-attribute-decoding-during-XML-schema-validation.patch --]
[-- Type: text/plain, Size: 2311 bytes --]
From 256366ed60f8795279b25f7b7b55e8089b4c6ff4 Mon Sep 17 00:00:00 2001
From: Alex Henrie <alexhenrie24@gmail.com>
Date: Thu, 26 May 2016 17:38:35 -0600
Subject: [PATCH] Fix attribute decoding during XML schema validation
For https://bugzilla.gnome.org/show_bug.cgi?id=766834
vctxt->parserCtxt is always NULL in xmlSchemaSAXHandleStartElementNs,
so this function can't call xmlStringLenDecodeEntities to decode the
entities.
---
xmlschemas.c | 30 +++++++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/xmlschemas.c b/xmlschemas.c
index e1b3a4f..59535e5 100644
--- a/xmlschemas.c
+++ b/xmlschemas.c
@@ -27391,6 +27391,7 @@ xmlSchemaSAXHandleStartElementNs(void *ctx,
* attributes yet.
*/
if (nb_attributes != 0) {
+ int valueLen, k, l;
xmlChar *value;
for (j = 0, i = 0; i < nb_attributes; i++, j += 5) {
@@ -27400,12 +27401,31 @@ xmlSchemaSAXHandleStartElementNs(void *ctx,
* libxml2 differs from normal SAX here in that it escapes all ampersands
* as & instead of delivering the raw converted string. Changing the
* behavior at this point would break applications that use this API, so
- * we are forced to work around it. There is no danger of accidentally
- * decoding some entity other than & in this step because without
- * unescaped ampersands there can be no other entities in the string.
+ * we are forced to work around it.
*/
- value = xmlStringLenDecodeEntities(vctxt->parserCtxt, attributes[j+3],
- attributes[j+4] - attributes[j+3], XML_SUBSTITUTE_REF, 0, 0, 0);
+ valueLen = attributes[j+4] - attributes[j+3];
+ value = xmlMallocAtomic(valueLen + 1);
+ if (value == NULL) {
+ xmlSchemaVErrMemory(vctxt,
+ "allocating string for decoded attribute",
+ NULL);
+ goto internal_error;
+ }
+ for (k = 0, l = 0; k < valueLen; l++) {
+ if (k < valueLen - 4 &&
+ attributes[j+3][k+0] == '&' &&
+ attributes[j+3][k+1] == '#' &&
+ attributes[j+3][k+2] == '3' &&
+ attributes[j+3][k+3] == '8' &&
+ attributes[j+3][k+4] == ';') {
+ value[l] = '&';
+ k += 5;
+ } else {
+ value[l] = attributes[j+3][k];
+ k++;
+ }
+ }
+ value[l] = '\0';
/*
* TODO: Set the node line.
*/
--
2.8.3
[-- Attachment #3: Type: text/plain, Size: 219 bytes --]
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
prev parent reply other threads:[~2017-10-02 19:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-30 17:07 xmlstarlet ignores XML attributes Kay Ulbrich
2017-10-02 19:10 ` David Stacey [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f6f71329-0582-985d-3dd2-ecb9191687bb@tiscali.co.uk \
--to=drstacey@tiscali.co.uk \
--cc=cygwin@cygwin.com \
--cc=kay_ulbrich@web.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).