Skip to content

Commit

Permalink
Merge pull request from GHSA-92x4-vfjf-rmf7
Browse files Browse the repository at this point in the history
  • Loading branch information
x64x6a authored Apr 21, 2023
1 parent c8988ba commit 89fa546
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion netbox/extras/models/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import urllib.parse
import uuid

from django.conf import settings
Expand Down Expand Up @@ -28,7 +29,7 @@
CloningMixin, CustomFieldsMixin, CustomLinksMixin, ExportTemplatesMixin, JobResultsMixin, TagsMixin, WebhooksMixin,
)
from utilities.querysets import RestrictedQuerySet
from utilities.utils import render_jinja2
from utilities.utils import clean_html, render_jinja2

__all__ = (
'ConfigRevision',
Expand Down Expand Up @@ -273,6 +274,18 @@ def render(self, context):
link = render_jinja2(self.link_url, context)
link_target = ' target="_blank"' if self.new_window else ''

# Sanitize link text
allowed_schemes = get_config().ALLOWED_URL_SCHEMES
text = clean_html(text, allowed_schemes)

# Sanitize link
link = urllib.parse.quote_plus(link, safe='/:?&')

# Verify link scheme is allowed
result = urllib.parse.urlparse(link)
if result.scheme and result.scheme not in allowed_schemes:
link = ""

return {
'text': text,
'link': link,
Expand Down

0 comments on commit 89fa546

Please sign in to comment.