Browse Source

Fix another couple bugs regarding template contexts and verify_safe().

tags/v0.2
Ben Kurtovic 11 years ago
parent
commit
4a725b7ac5
2 changed files with 16 additions and 3 deletions
  1. +15
    -3
      mwparserfromhell/parser/tokenizer.c
  2. +1
    -0
      mwparserfromhell/parser/tokenizer.h

+ 15
- 3
mwparserfromhell/parser/tokenizer.c View File

@@ -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;


+ 1
- 0
mwparserfromhell/parser/tokenizer.h View File

@@ -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: */



Loading…
Cancel
Save