[libxslt] Allow {URI}NCName syntax for user parameters
- From: Nick Wellnhofer <nwellnhof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxslt] Allow {URI}NCName syntax for user parameters
- Date: Mon, 28 Mar 2016 14:07:50 +0000 (UTC)
commit 891681e3e948f31732229f53cb6db7215f740fc7
Author: Nick Wellnhofer <wellnhofer aevum de>
Date: Mon Mar 28 16:02:18 2016 +0200
Allow {URI}NCName syntax for user parameters
Thanks to Richard Smith <richard ex-parrot com> for the patch. Applied
with minor changes.
Fixes bug #764195.
https://bugzilla.gnome.org/show_bug.cgi?id=764195
libxslt/variables.c | 42 ++++++++++++++++++++++++++++--------------
xsltproc/xsltproc.c | 1 +
2 files changed, 29 insertions(+), 14 deletions(-)
---
diff --git a/libxslt/variables.c b/libxslt/variables.c
index 3224116..345123d 100644
--- a/libxslt/variables.c
+++ b/libxslt/variables.c
@@ -1445,21 +1445,35 @@ xsltProcessUserParamInternal(xsltTransformContextPtr ctxt,
/*
* Name lookup
*/
-
- name = xsltSplitQName(ctxt->dict, name, &prefix);
href = NULL;
- if (prefix != NULL) {
- xmlNsPtr ns;
- ns = xmlSearchNs(style->doc, xmlDocGetRootElement(style->doc),
- prefix);
- if (ns == NULL) {
- xsltTransformError(ctxt, style, NULL,
- "user param : no namespace bound to prefix %s\n", prefix);
- href = NULL;
- } else {
- href = ns->href;
- }
+ if (name[0] == '{') {
+ int len = 0;
+
+ while ((name[len] != 0) && (name[len] != '}')) len++;
+ if (name[len] == 0) {
+ xsltTransformError(ctxt, style, NULL,
+ "user param : malformed parameter name : %s\n", name);
+ } else {
+ href = xmlDictLookup(ctxt->dict, &name[1], len-1);
+ name = xmlDictLookup(ctxt->dict, &name[len + 1], -1);
+ }
+ }
+ else {
+ name = xsltSplitQName(ctxt->dict, name, &prefix);
+ if (prefix != NULL) {
+ xmlNsPtr ns;
+
+ ns = xmlSearchNs(style->doc, xmlDocGetRootElement(style->doc),
+ prefix);
+ if (ns == NULL) {
+ xsltTransformError(ctxt, style, NULL,
+ "user param : no namespace bound to prefix %s\n", prefix);
+ href = NULL;
+ } else {
+ href = ns->href;
+ }
+ }
}
if (name == NULL)
diff --git a/xsltproc/xsltproc.c b/xsltproc/xsltproc.c
index ead3893..3c83abd 100644
--- a/xsltproc/xsltproc.c
+++ b/xsltproc/xsltproc.c
@@ -523,6 +523,7 @@ static void usage(const char *name) {
#endif
printf("\t--encoding: the input document character encoding\n");
printf("\t--param name value : pass a (parameter,value) pair\n");
+ printf("\t name is a QName or a string of the form {URI}NCName.\n");
printf("\t value is an UTF8 XPath expression.\n");
printf("\t string values must be quoted like \"'string'\"\n or");
printf("\t use stringparam to avoid it\n");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]