ansi2json: Handle multiple CRs in line endings
On Windows-based CI pipelines we can get text where line endings consist of multiple CRs followed by a LF. That's because many programs use LF line endings internally and convert to CRLF on output. That conversion is done without any check, so if the string is already CRLF we get CRCRLF. That's the case of the Microsoft C/C++ Runtime Library, CPython, etc.
Handle that in ansi2json by matching multiple CRs followed by a LF.
before | after |
---|---|
With this MR the Python's traceback is correctly shown
See https://gitlab.gnome.org/GNOME/glib/-/issues/3464 for more informations
The issue can be reproduced by executing this Python script in a Windows job:
import subprocess
result = subprocess.run(['tar', '-tf', 'filename.tar'], capture_output=True)
print('--- stdout ---')
print(result.stdout.decode('utf-8'))
print('--- stderr ---')
print(result.stderr.decode('utf-8'))
Helps #218771, #342686 (closed)
Edited by lb90