1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 12:25:09 +03:00

Fix caret in regexp character group

Apply Per Hedeland's patch from

    https://bugzilla.gnome.org/show_bug.cgi?id=779751

Fixes #188.
This commit is contained in:
Nick Wellnhofer 2020-10-25 20:21:43 +01:00
parent 8a85263f13
commit 7d6837ba0e

View File

@ -5155,7 +5155,7 @@ xmlFAParsePosCharGroup(xmlRegParserCtxtPtr ctxt) {
} else { } else {
xmlFAParseCharRange(ctxt); xmlFAParseCharRange(ctxt);
} }
} while ((CUR != ']') && (CUR != '^') && (CUR != '-') && } while ((CUR != ']') && (CUR != '-') &&
(CUR != 0) && (ctxt->error == 0)); (CUR != 0) && (ctxt->error == 0));
} }
@ -5170,34 +5170,31 @@ xmlFAParsePosCharGroup(xmlRegParserCtxtPtr ctxt) {
*/ */
static void static void
xmlFAParseCharGroup(xmlRegParserCtxtPtr ctxt) { xmlFAParseCharGroup(xmlRegParserCtxtPtr ctxt) {
int n = ctxt->neg; int neg = ctxt->neg;
while ((CUR != ']') && (ctxt->error == 0)) {
if (CUR == '^') {
int neg = ctxt->neg;
NEXT; if (CUR == '^') {
ctxt->neg = !ctxt->neg; NEXT;
xmlFAParsePosCharGroup(ctxt); ctxt->neg = !ctxt->neg;
ctxt->neg = neg; xmlFAParsePosCharGroup(ctxt);
} else if ((CUR == '-') && (NXT(1) == '[')) { ctxt->neg = neg;
int neg = ctxt->neg; }
ctxt->neg = 2; while ((CUR != ']') && (ctxt->error == 0)) {
if ((CUR == '-') && (NXT(1) == '[')) {
NEXT; /* eat the '-' */ NEXT; /* eat the '-' */
NEXT; /* eat the '[' */ NEXT; /* eat the '[' */
ctxt->neg = 2;
xmlFAParseCharGroup(ctxt); xmlFAParseCharGroup(ctxt);
ctxt->neg = neg;
if (CUR == ']') { if (CUR == ']') {
NEXT; NEXT;
} else { } else {
ERROR("charClassExpr: ']' expected"); ERROR("charClassExpr: ']' expected");
break;
} }
ctxt->neg = neg;
break; break;
} else if (CUR != ']') { } else {
xmlFAParsePosCharGroup(ctxt); xmlFAParsePosCharGroup(ctxt);
} }
} }
ctxt->neg = n;
} }
/** /**