diff options
| author | Andi Albrecht <albrecht.andi@gmail.com> | 2021-09-07 12:27:28 +0200 |
|---|---|---|
| committer | Andi Albrecht <albrecht.andi@gmail.com> | 2021-09-10 08:49:09 +0200 |
| commit | 8238a9e450ed1524e40cb3a8b0b3c00606903aeb (patch) | |
| tree | 76757406d040030ad733b946eb09fb06ed11e5fc /sqlparse | |
| parent | e66046785b816e5c2d22f101f36faefd19c4a771 (diff) | |
| download | sqlparse-8238a9e450ed1524e40cb3a8b0b3c00606903aeb.tar.gz | |
Optimize regular expression for identifying line breaks in comments.
Diffstat (limited to 'sqlparse')
| -rw-r--r-- | sqlparse/filters/others.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sqlparse/filters/others.py b/sqlparse/filters/others.py index e0e1ca1..6905f2d 100644 --- a/sqlparse/filters/others.py +++ b/sqlparse/filters/others.py @@ -22,7 +22,10 @@ class StripCommentsFilter: def _get_insert_token(token): """Returns either a whitespace or the line breaks from token.""" # See issue484 why line breaks should be preserved. - m = re.search(r'((\r\n|\r|\n)+) *$', token.value) + # Note: The actual value for a line break is replaced by \n + # in SerializerUnicode which will be executed in the + # postprocessing state. + m = re.search(r'((\r|\n)+) *$', token.value) if m is not None: return sql.Token(T.Whitespace.Newline, m.groups()[0]) else: |
