From 4ad1450995cd374fd6766e329be57af7e6b0f649 Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Thu, 17 Jan 2002 22:40:42 +0000 Subject: [PATCH] fixed I18N problemes in the template parser pointed out by Xavier Cazin * libxslt/pattern.c: fixed I18N problemes in the template parser pointed out by Xavier Cazin * tests/docs/Makefile.am tests/docs/bug-69.xml tests/general/Makefile.am tests/general/bug-69.*: added a specific example in the regression tests Daniel --- ChangeLog | 8 +++ libxslt/pattern.c | 124 ++++++++++++++++++++++------------------------ tests/docs/Makefile.am | 1 + tests/docs/bug-69.xml | 2 + tests/general/Makefile.am | 1 + tests/general/bug-69.out | 2 + tests/general/bug-69.xsl | 12 +++++ 7 files changed, 84 insertions(+), 66 deletions(-) create mode 100644 tests/docs/bug-69.xml create mode 100644 tests/general/bug-69.out create mode 100644 tests/general/bug-69.xsl diff --git a/ChangeLog b/ChangeLog index 1700f53..b23d02c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Thu Jan 17 23:39:00 CET 2002 Daniel Veillard + + * libxslt/pattern.c: fixed I18N problemes in the template parser + pointed out by Xavier Cazin + * tests/docs/Makefile.am tests/docs/bug-69.xml + tests/general/Makefile.am tests/general/bug-69.*: added a + specific example in the regression tests + Thu Jan 17 10:40:03 CET 2002 Daniel Veillard * Makefile.am libexslt/common.c libexslt/date.c libexslt/exslt.c diff --git a/libxslt/pattern.c b/libxslt/pattern.c index c213434..a2fcb0d 100644 --- a/libxslt/pattern.c +++ b/libxslt/pattern.c @@ -850,36 +850,43 @@ xsltTestCompMatchList(xsltTransformContextPtr ctxt, xmlNodePtr node, static xmlChar * xsltScanLiteral(xsltParserContextPtr ctxt) { - const xmlChar *q; + const xmlChar *q, *cur; xmlChar *ret = NULL; + int val, len; SKIP_BLANKS; if (CUR == '"') { NEXT; - q = CUR_PTR; - while ((IS_CHAR(CUR)) && (CUR != '"')) - NEXT; - if (!IS_CHAR(CUR)) { - /* XP_ERROR(XPATH_UNFINISHED_LITERAL_ERROR); */ + cur = q = CUR_PTR; + val = xmlStringCurrentChar(NULL, cur, &len); + while ((IS_CHAR(val)) && (val != '"')) { + cur += len; + val = xmlStringCurrentChar(NULL, cur, &len); + } + if (!IS_CHAR(val)) { ctxt->error = 1; return(NULL); } else { - ret = xmlStrndup(q, CUR_PTR - q); - NEXT; + ret = xmlStrndup(q, cur - q); } + cur += len; + CUR_PTR = cur; } else if (CUR == '\'') { NEXT; - q = CUR_PTR; - while ((IS_CHAR(CUR)) && (CUR != '\'')) - NEXT; - if (!IS_CHAR(CUR)) { - /* XP_ERROR(XPATH_UNFINISHED_LITERAL_ERROR); */ + cur = q = CUR_PTR; + val = xmlStringCurrentChar(NULL, cur, &len); + while ((IS_CHAR(val)) && (val != '\'')) { + cur += len; + val = xmlStringCurrentChar(NULL, cur, &len); + } + if (!IS_CHAR(val)) { ctxt->error = 1; return(NULL); } else { - ret = xmlStrndup(q, CUR_PTR - q); - NEXT; + ret = xmlStrndup(q, cur - q); } + cur += len; + CUR_PTR = cur; } else { /* XP_ERROR(XPATH_START_LITERAL_ERROR); */ ctxt->error = 1; @@ -904,36 +911,28 @@ xsltScanLiteral(xsltParserContextPtr ctxt) { static xmlChar * xsltScanName(xsltParserContextPtr ctxt) { - xmlChar buf[XML_MAX_NAMELEN]; - int len = 0; + const xmlChar *q, *cur; + xmlChar *ret = NULL; + int val, len; SKIP_BLANKS; - if (!IS_LETTER(CUR) && (CUR != '_') && - (CUR != ':')) { + + cur = q = CUR_PTR; + val = xmlStringCurrentChar(NULL, cur, &len); + if (!IS_LETTER(val) && (val != '_') && (val != ':')) return(NULL); - } - while ((IS_LETTER(NXT(len))) || (IS_DIGIT(NXT(len))) || - (NXT(len) == '.') || (NXT(len) == '-') || - (NXT(len) == '_') || - (IS_COMBINING(NXT(len))) || - (IS_EXTENDER(NXT(len)))) { - buf[len] = NXT(len); - len++; - if (len >= XML_MAX_NAMELEN) { - xmlGenericError(xmlGenericErrorContext, - "xsltScanName: reached XML_MAX_NAMELEN limit\n"); - while ((IS_LETTER(NXT(len))) || (IS_DIGIT(NXT(len))) || - (NXT(len) == '.') || (NXT(len) == '-') || - (NXT(len) == '_') || (NXT(len) == ':') || - (IS_COMBINING(NXT(len))) || - (IS_EXTENDER(NXT(len)))) - len++; - break; - } + while ((IS_LETTER(val)) || (IS_DIGIT(val)) || + (val == '.') || (val == '-') || + (val == '_') || + (IS_COMBINING(val)) || + (IS_EXTENDER(val))) { + cur += len; + val = xmlStringCurrentChar(NULL, cur, &len); } - SKIP(len); - return(xmlStrndup(buf, len)); + ret = xmlStrndup(q, cur - q); + CUR_PTR = cur; + return(ret); } /** @@ -947,35 +946,28 @@ xsltScanName(xsltParserContextPtr ctxt) { static xmlChar * xsltScanNCName(xsltParserContextPtr ctxt) { - xmlChar buf[XML_MAX_NAMELEN]; - int len = 0; + const xmlChar *q, *cur; + xmlChar *ret = NULL; + int val, len; SKIP_BLANKS; - if (!IS_LETTER(CUR) && (CUR != '_')) { + + cur = q = CUR_PTR; + val = xmlStringCurrentChar(NULL, cur, &len); + if (!IS_LETTER(val) && (val != '_')) return(NULL); - } - while ((IS_LETTER(NXT(len))) || (IS_DIGIT(NXT(len))) || - (NXT(len) == '.') || (NXT(len) == '-') || - (NXT(len) == '_') || - (IS_COMBINING(NXT(len))) || - (IS_EXTENDER(NXT(len)))) { - buf[len] = NXT(len); - len++; - if (len >= XML_MAX_NAMELEN) { - xmlGenericError(xmlGenericErrorContext, - "xsltScanNCName: reached XML_MAX_NAMELEN limit\n"); - while ((IS_LETTER(NXT(len))) || (IS_DIGIT(NXT(len))) || - (NXT(len) == '.') || (NXT(len) == '-') || - (NXT(len) == '_') || - (IS_COMBINING(NXT(len))) || - (IS_EXTENDER(NXT(len)))) - len++; - break; - } + while ((IS_LETTER(val)) || (IS_DIGIT(val)) || + (val == '.') || (val == '-') || + (val == '_') || + (IS_COMBINING(val)) || + (IS_EXTENDER(val))) { + cur += len; + val = xmlStringCurrentChar(NULL, cur, &len); } - SKIP(len); - return(xmlStrndup(buf, len)); + ret = xmlStrndup(q, cur - q); + CUR_PTR = cur; + return(ret); } /** @@ -1349,7 +1341,7 @@ parse_predicate: NEXT; q = CUR_PTR; /* TODO: avoid breaking in strings ... */ - while (IS_CHAR(CUR)) { + while (CUR != 0) { /* Skip over nested predicates */ if (CUR == '[') level++; @@ -1360,7 +1352,7 @@ parse_predicate: } NEXT; } - if (!IS_CHAR(CUR)) { + if (CUR == 0) { xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */ xsltGenericError(xsltGenericErrorContext, "xsltCompileStepPattern : ']' expected\n"); diff --git a/tests/docs/Makefile.am b/tests/docs/Makefile.am index 86f7d12..9461edc 100644 --- a/tests/docs/Makefile.am +++ b/tests/docs/Makefile.am @@ -69,6 +69,7 @@ EXTRA_DIST = \ bug-65.xml \ bug-66.xml \ bug-68.xml \ + bug-69.xml \ character.xml \ array.xml \ items.xml diff --git a/tests/docs/bug-69.xml b/tests/docs/bug-69.xml new file mode 100644 index 0000000..d2c746b --- /dev/null +++ b/tests/docs/bug-69.xml @@ -0,0 +1,2 @@ + +Failure diff --git a/tests/general/Makefile.am b/tests/general/Makefile.am index ccbf4b7..170a5a0 100644 --- a/tests/general/Makefile.am +++ b/tests/general/Makefile.am @@ -72,6 +72,7 @@ EXTRA_DIST = \ bug-65.ent bug-65.out bug-65.xsl \ bug-66.out bug-66.xsl \ bug-68.out bug-68.xsl \ + bug-69.out bug-69.xsl \ character.out character.xsl \ character2.out character2.xsl \ itemschoose.out itemschoose.xsl \ diff --git a/tests/general/bug-69.out b/tests/general/bug-69.out new file mode 100644 index 0000000..77c975e --- /dev/null +++ b/tests/general/bug-69.out @@ -0,0 +1,2 @@ + +Success diff --git a/tests/general/bug-69.xsl b/tests/general/bug-69.xsl new file mode 100644 index 0000000..7f765bb --- /dev/null +++ b/tests/general/bug-69.xsl @@ -0,0 +1,12 @@ + + + + + + Success + + + + -- 2.7.4