Ticket #4171: forbide_newlines_in_tags.diff

File forbide_newlines_in_tags.diff, 1.1 KB (added by tonnzor <tonn81@…>, 8 years ago)
  • __init__.py

     
    9393                                          re.escape(COMMENT_TAG_START), re.escape(COMMENT_TAG_END)))
    9494# matches if the string is valid number
    9595number_re = re.compile(r'[-+]?(\d+|\d*\.\d+)$')
     96newline_re = re.compile(r'[\n\r]')
    9697
    9798# global dictionary of libraries that have been loaded using get_library
    9899libraries = {}
     
    199200
    200201    def create_token(self,token_string):
    201202        "Convert the given token string into a new Token object and return it"
    202         if token_string.startswith(VARIABLE_TAG_START):
     203        if newline_re.search(token_string):
     204            token = Token(TOKEN_TEXT, token_string)
     205        elif token_string.startswith(VARIABLE_TAG_START):
    203206            token = Token(TOKEN_VAR, token_string[len(VARIABLE_TAG_START):-len(VARIABLE_TAG_END)].strip())
    204207        elif token_string.startswith(BLOCK_TAG_START):
    205208            token = Token(TOKEN_BLOCK, token_string[len(BLOCK_TAG_START):-len(BLOCK_TAG_END)].strip())
Back to Top