]> git.ipfire.org Git - thirdparty/jinja.git/commit
Split lines in lexer only by \r\n, \r and \n 1366/head
authorMatěj Volf <mat.volfik@gmail.com>
Tue, 9 Mar 2021 13:19:58 +0000 (14:19 +0100)
committerDavid Lord <davidism@gmail.com>
Mon, 5 Apr 2021 18:46:36 +0000 (11:46 -0700)
commit9dae67bcc8dbc389e0ceef12f1fa04352ef75b8e
treeb7c6ce202b0302fcd5533b419fb8660071ce297b
parent59de6fbde98de6719758b773a77f0559756756b5
Split lines in lexer only by \r\n, \r and \n

Python str.splitlines() splits by more characters[1], which, however,
causes problems when keeping these special characters in processed
templates is desirable, i.e. these bug reports: #769, #952, #1313.

The keep_trailing_newlines logic is reworked because splitlines()
removes them already (so they had to be added), while re.split doesn't
so they have to be removed.

[1] https://docs.python.org/3/library/stdtypes.html#str.splitlines
CHANGES.rst
src/jinja2/lexer.py
tests/test_regression.py