Ticket #5971: tokenparser_filter_fix.diff
File tokenparser_filter_fix.diff, 2.4 KB (added by , 17 years ago) |
---|
-
django/template/__init__.py
458 458 "A microparser that parses for a value: some string constant or variable name." 459 459 subject = self.subject 460 460 i = self.pointer 461 462 def __next_space_index(subject, i): 463 """Increment pointer until a real space (i.e. a space not within quotes) is encountered""" 464 while i < len(subject) and subject[i] not in (' ', '\t'): 465 if subject[i] in ('"', "'"): 466 c = subject[i] 467 i += 1 468 while i < len(subject) and subject[i] != c: 469 i += 1 470 if i >= len(subject): 471 raise TemplateSyntaxError, "Searching for value. Unexpected end of string in column %d: %s" % (i, subject) 472 i += 1 473 return i 474 461 475 if i >= len(subject): 462 476 raise TemplateSyntaxError, "Searching for value. Expected another value but found end of string: %s" % subject 463 477 if subject[i] in ('"', "'"): … … 468 482 if i >= len(subject): 469 483 raise TemplateSyntaxError, "Searching for value. Unexpected end of string in column %d: %s" % (i, subject) 470 484 i += 1 485 486 # Continue parsing until next "real" space, so that filters are also included 487 i = __next_space_index(subject, i) 488 471 489 res = subject[p:i] 472 490 while i < len(subject) and subject[i] in (' ', '\t'): 473 491 i += 1 … … 476 494 return res 477 495 else: 478 496 p = i 479 while i < len(subject) and subject[i] not in (' ', '\t'): 480 if subject[i] in ('"', "'"): 481 c = subject[i] 482 i += 1 483 while i < len(subject) and subject[i] != c: 484 i += 1 485 if i >= len(subject): 486 raise TemplateSyntaxError, "Searching for value. Unexpected end of string in column %d: %s" % (i, subject) 487 i += 1 497 i = __next_space_index(subject, i) 488 498 s = subject[p:i] 489 499 while i < len(subject) and subject[i] in (' ', '\t'): 490 500 i += 1