Ticket #3100: 3100-backwards-compatible.patch

File 3100-backwards-compatible.patch, 2.1 KB (added by Aymeric Augustin, 13 years ago)
  • django/template/base.py

     
    250250                var_node = self.create_variable_node(filter_expression)
    251251                self.extend_nodelist(nodelist, var_node, token)
    252252            elif token.token_type == TOKEN_BLOCK:
    253                 if token.contents in parse_until:
     253                try:
     254                    command = token.contents.split()[0]
     255                except IndexError:
     256                    self.empty_block_tag(token)
     257                if command in parse_until:
    254258                    # put token back on token list so calling
    255259                    # code knows why it terminated
    256260                    self.prepend_token(token)
    257261                    return nodelist
    258                 try:
    259                     command = token.contents.split()[0]
    260                 except IndexError:
    261                     self.empty_block_tag(token)
    262262                # execute callback function for this tag and append
    263263                # resulting node
    264264                self.enter_command(command, token)
  • django/template/loader_tags.py

     
    189189        parser.__loaded_blocks.append(block_name)
    190190    except AttributeError: # parser.__loaded_blocks isn't a list yet
    191191        parser.__loaded_blocks = [block_name]
    192     nodelist = parser.parse(('endblock', 'endblock %s' % block_name))
    193     parser.delete_first_token()
     192    nodelist = parser.parse(('endblock',))
     193
     194    # This check is kept for backwards-compatibility. See #3100.
     195    endblock = parser.next_token()
     196    acceptable_endblocks = ('endblock', 'endblock %s' % block_name)
     197    if endblock.contents not in acceptable_endblocks:
     198        parser.invalid_block_tag(endblock, 'endblock', acceptable_endblocks)
     199
    194200    return BlockNode(block_name, nodelist)
    195201
    196202@register.tag('extends')
Back to Top