Skip to content

Jinja2 condition not working anymore in Custom Link URL field #12694

@tux-mania

Description

@tux-mania

NetBox version

v3.5.2

Python version

3.9

Steps to Reproduce

  1. Create a custom link with jinja2 condition in "Link URL" field. For example, I set a new Custom Link named "website" with the following on the Link URL field:
{% if object.tenant_id == 1 %}
https://www.google.com
{% else %}
https://www.duckduckgo.com
{% endif %}

Expected Behavior

According to my object tenant id, it should open a webpage on google.com or duduckgo.com when clicking on the custom link button.

Observed Behavior

Instead, I got the following error:
netbox_sanitize_url

This behaviour seems related to the feature "Sanitize rendered custom link HTML" #12205 .
In fact, when removing the code added in the commit 89fa546, the expected behavior happens.

Thank you for your help.

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions