diff --git a/webapp/services/wim.py b/webapp/services/wim.py index 15c1713..4dc66d9 100644 --- a/webapp/services/wim.py +++ b/webapp/services/wim.py @@ -125,7 +125,9 @@ def _split_lines(content): Rejoining with eol.join(...) reproduces a trailing newline because a trailing terminator yields a final empty element. """ - return content.replace("\r\n", "\n").replace("\r", "\n").split("\n") + # Collapse any run of CRs before a newline (handles CRLF and a doubled + # \r\r\n that a bad CRLF-conversion can leave behind), then lone CR. + return re.sub(r"\r+\n", "\n", content).replace("\r", "\n").split("\n") # --- Shared regexes ---------------------------------------------------------