Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions openwisp_utils/admin_theme/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def get_dashboard_context(request):
filters.append(label)
label = labels_i18n[qs_key]
else:
filters.append(label)
# HTML escape labels coming from values in the DB
# to avoid possible XSS attacks caused by
# malicious DB values set by users
Expand Down
9 changes: 9 additions & 0 deletions tests/test_project/tests/test_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,12 @@ def test_get_dashboard_context_html_escape(self):
context["dashboard_charts"][1]["query_params"]["labels"][0],
"<strong>Projects with operators</strong>",
)

def test_filter_not_double_encoded(self):
project = Project.objects.create(name="Dongwon T&I")
Operator.objects.create(project=project, first_name="test", last_name="test")
request = MockRequest(user=MockUser(is_superuser=True))
context = get_dashboard_context(request)
chart = context["dashboard_charts"][0]
self.assertIn("Dongwon T&I", chart["filters"])
self.assertIn("Dongwon T&I", chart["query_params"]["labels"])
Loading