diff --git a/HISTORY.rst b/HISTORY.rst index 1103aef4..0f7a1c93 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,6 +7,7 @@ History * Provide CVSS scores on full report, when available * Fixed used DB wrong info +* Support line breaks on advisories 1.10.1 (2021-01-03) ------------------- diff --git a/safety/formatter.py b/safety/formatter.py index 45d2d2d5..a8ff3241 100644 --- a/safety/formatter.py +++ b/safety/formatter.py @@ -135,16 +135,22 @@ def render(vulns, full, checked_packages, used_db): )) table.append(SheetReport.REPORT_SECTION) - descr = get_advisory(vuln) - - for pn, paragraph in enumerate(descr.replace('\r', '').split('\n\n')): - if pn: - table.append("| {:76} |".format('')) - for line in textwrap.wrap(paragraph, width=76): + advisory_lines = get_advisory(vuln).replace( + '\r', '' + ).splitlines() + + for line in advisory_lines: + if line == '': + table.append("| {:76} |".format(" ")) + for wrapped_line in textwrap.wrap(line, width=76): try: - table.append("| {:76} |".format(line.encode('utf-8'))) + table.append("| {:76} |".format( + wrapped_line.encode('utf-8') + )) except TypeError: - table.append("| {:76} |".format(line)) + table.append("| {:76} |".format( + wrapped_line + )) # append the REPORT_SECTION only if this isn't the last entry if n + 1 < len(vulns): table.append(SheetReport.REPORT_SECTION)