diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2020-10-25 20:21:43 +0100 |
---|---|---|
committer | Nick Wellnhofer <wellnhofer@aevum.de> | 2020-10-25 20:21:43 +0100 |
commit | 7d6837ba0e282e94eb8630ad791f427e44a57491 (patch) | |
tree | e0a224682cead49b9bbab492385cf97adea42a51 /xmlregexp.c | |
parent | 8a85263f132b5c9e6a552269166600ab9c1e1426 (diff) | |
download | libxml2-7d6837ba0e282e94eb8630ad791f427e44a57491.tar.gz |
Fix caret in regexp character group
Apply Per Hedeland's patch from
https://bugzilla.gnome.org/show_bug.cgi?id=779751
Fixes #188.
Diffstat (limited to 'xmlregexp.c')
-rw-r--r-- | xmlregexp.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/xmlregexp.c b/xmlregexp.c index f971f0c8..40dabb20 100644 --- a/xmlregexp.c +++ b/xmlregexp.c @@ -5155,7 +5155,7 @@ xmlFAParsePosCharGroup(xmlRegParserCtxtPtr ctxt) { } else { xmlFAParseCharRange(ctxt); } - } while ((CUR != ']') && (CUR != '^') && (CUR != '-') && + } while ((CUR != ']') && (CUR != '-') && (CUR != 0) && (ctxt->error == 0)); } @@ -5170,34 +5170,31 @@ xmlFAParsePosCharGroup(xmlRegParserCtxtPtr ctxt) { */ static void xmlFAParseCharGroup(xmlRegParserCtxtPtr ctxt) { - int n = ctxt->neg; - while ((CUR != ']') && (ctxt->error == 0)) { - if (CUR == '^') { - int neg = ctxt->neg; + int neg = ctxt->neg; - NEXT; - ctxt->neg = !ctxt->neg; - xmlFAParsePosCharGroup(ctxt); - ctxt->neg = neg; - } else if ((CUR == '-') && (NXT(1) == '[')) { - int neg = ctxt->neg; - ctxt->neg = 2; + if (CUR == '^') { + NEXT; + ctxt->neg = !ctxt->neg; + xmlFAParsePosCharGroup(ctxt); + ctxt->neg = neg; + } + while ((CUR != ']') && (ctxt->error == 0)) { + if ((CUR == '-') && (NXT(1) == '[')) { NEXT; /* eat the '-' */ NEXT; /* eat the '[' */ + ctxt->neg = 2; xmlFAParseCharGroup(ctxt); + ctxt->neg = neg; if (CUR == ']') { NEXT; } else { ERROR("charClassExpr: ']' expected"); - break; } - ctxt->neg = neg; break; - } else if (CUR != ']') { + } else { xmlFAParsePosCharGroup(ctxt); } } - ctxt->neg = n; } /** |