Pārlūkot izejas kodu

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

tags/v0.2
Ben Kurtovic pirms 12 gadiem
vecāks
revīzija
4a725b7ac5
2 mainītis faili ar 16 papildinājumiem un 3 dzēšanām
  1. +15
    -3
      mwparserfromhell/parser/tokenizer.c
  2. +1
    -0
      mwparserfromhell/parser/tokenizer.h

+ 15
- 3
mwparserfromhell/parser/tokenizer.c Parādīt failu

@@ -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 Parādīt failu

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



Notiek ielāde…
Atcelt
Saglabāt