diff --git a/mwparserfromhell/parser/tokenizer.c b/mwparserfromhell/parser/tokenizer.c index 0016515..57c6a62 100644 --- a/mwparserfromhell/parser/tokenizer.c +++ b/mwparserfromhell/parser/tokenizer.c @@ -1153,18 +1153,30 @@ Tokenizer_verify_safe(Tokenizer* self, int context, Py_UNICODE data) self->topstack->context |= LC_FAIL_NEXT; return; } + if (data == *"|") { + if (context & LC_FAIL_ON_TEXT) { + self->topstack->context ^= LC_FAIL_ON_TEXT; + return; + } + } } else if (context & (LC_TEMPLATE_PARAM_KEY | LC_ARGUMENT_NAME)) { - if (context & LC_FAIL_ON_LBRACE) { - if (data == *"{") { + if (context & LC_FAIL_ON_EQUALS) { + if (data == *"=") { self->topstack->context |= LC_FAIL_NEXT; return; } + } + else if (context & LC_FAIL_ON_LBRACE) { + if (data == *"{") { + self->topstack->context |= (context & LC_TEMPLATE) ? LC_FAIL_ON_EQUALS : LC_FAIL_NEXT; + return; + } self->topstack->context ^= LC_FAIL_ON_LBRACE; } else if (context & LC_FAIL_ON_RBRACE) { if (data == *"}") { - self->topstack->context |= LC_FAIL_NEXT; + self->topstack->context |= (context & LC_TEMPLATE) ? LC_FAIL_ON_EQUALS : LC_FAIL_NEXT; return; } self->topstack->context ^= LC_FAIL_ON_RBRACE; diff --git a/mwparserfromhell/parser/tokenizer.h b/mwparserfromhell/parser/tokenizer.h index 67c39cd..2484d4f 100644 --- a/mwparserfromhell/parser/tokenizer.h +++ b/mwparserfromhell/parser/tokenizer.h @@ -119,6 +119,7 @@ static PyObject* TagCloseClose; #define LC_FAIL_NEXT 0x10000 #define LC_FAIL_ON_LBRACE 0x20000 #define LC_FAIL_ON_RBRACE 0x40000 +#define LC_FAIL_ON_EQUALS 0x80000 /* Global contexts: */