Netbox mangles code inside markdown code blocks #6527

Closed
opened 2025-12-29 19:42:00 +01:00 by adam · 3 comments
Owner

Originally created by @crazzy on GitHub (Jun 1, 2022).

NetBox version

v3.2.2

Python version

3.10

Steps to Reproduce

In journal entry for a site, add the following markdown:

    # Stuff

    ```
    cat <<EOF>filename
    File contents
    EOF
    ```

Then save and view.

Expected Behavior

I would have expected this to render correctly like it does on github:

Stuff

cat <<EOF>filename
File contents
EOF

Observed Behavior

Netbox mangles the code inside the code blocks removing specifically the <EOF> part of the code. So the resulting output in netbox is this:

Stuff

cat <filename
File contents
EOF
Originally created by @crazzy on GitHub (Jun 1, 2022). ### NetBox version v3.2.2 ### Python version 3.10 ### Steps to Reproduce In journal entry for a site, add the following markdown: # Stuff ``` cat <<EOF>filename File contents EOF ``` Then save and view. ### Expected Behavior I would have expected this to render *correctly* like it does on github: # Stuff ``` cat <<EOF>filename File contents EOF ``` ### Observed Behavior Netbox mangles the code inside the code blocks removing specifically the `<EOF>` part of the code. So the resulting output in netbox is this: # Stuff ``` cat <filename File contents EOF ```
adam added the type: bugstatus: duplicate labels 2025-12-29 19:42:00 +01:00
adam closed this issue 2025-12-29 19:42:00 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jun 1, 2022):

Thank you for submitting this issue, however it appears that this topic has already been raised. Please see issue #9108 for further discussion.

@jeremystretch commented on GitHub (Jun 1, 2022): Thank you for submitting this issue, however it appears that this topic has already been raised. Please see issue #9108 for further discussion.
Author
Owner

@crazzy commented on GitHub (Jun 10, 2022):

Sorry if I'm missing something, but I don't see how this is the same issue as #9108 since in this case the angle brackets are inside a code block in the Markdown, meaning they should not in any way be parsed. Anything inside a code block should be left as is, shouldn't it?

@crazzy commented on GitHub (Jun 10, 2022): Sorry if I'm missing something, but I don't see how this is the same issue as #9108 since in this case the angle brackets are inside a code block in the Markdown, meaning they should not in any way be parsed. Anything inside a code block should be left as is, shouldn't it?
Author
Owner

@kkthxbye-code commented on GitHub (Jun 10, 2022):

@crazzy - The cause is the same. No reason to have two issues for the same problem.

f415d81049/netbox/utilities/templatetags/builtins/filters.py (L150)

Markdown rendering needs a general rework, removing the workarounds added to prevent XSS and using a HTML sanitizer like bleach instead.

@kkthxbye-code commented on GitHub (Jun 10, 2022): @crazzy - The cause is the same. No reason to have two issues for the same problem. https://github.com/netbox-community/netbox/blob/f415d810491d9eb1791eb38a2d9bec5d0b1c8aee/netbox/utilities/templatetags/builtins/filters.py#L150 Markdown rendering needs a general rework, removing the workarounds added to prevent XSS and using a HTML sanitizer like bleach instead.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6527