#1683

[BUG] PDF export loses indentation in proof-of-concept code

Opensamirhvbropened 1d ago

Describe the bug

The PDF exporter collapses spaces in proof-of-concept code and fenced code blocks. An indented Python snippet can be read and copied from the viewer, but the exported PDF places each line at the same horizontal position. Copying the exported snippet produces invalid Python.

To Reproduce

On main at 06015506625a78b981ae0b34be40239fc1b389be, use a synthetic finding with this poc_script_code and export its report as a PDF.

def reproduce():
    if True:
        print("example")
    return 1

The original snippet compiles. The text extracted from the PDF loses the four- and eight-space indents and fails with IndentationError. The same indentation loss is visible on the rendered page. Raw code fields and fenced Markdown blocks pass escaped text through a ReportLab paragraph, which collapses ordinary spaces.

Expected behavior

The PDF should preserve code indentation and repeated spaces while continuing to escape markup, wrap long lines, and paginate large blocks. This keeps the reproduction steps usable in the exported report.

Environment

macOS, Python 3.12.14, frozen project dependencies, local PDF generation from synthetic report data.

Activity

0

No activity yet.