Skip to content

Commit

Permalink
Merge pull request #1794 from 18F/address-findings
Browse files Browse the repository at this point in the history
API: do not echo user input
  • Loading branch information
cantsin authored Sep 16, 2024
2 parents a74d006 + e619d92 commit f4750d2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions tock/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from django.contrib.auth import get_user_model
from django.db import connection
from django.db.models import Count, F
from django.utils.html import escape

from rest_framework import serializers, generics
from rest_framework.exceptions import ParseError
Expand Down Expand Up @@ -257,9 +256,7 @@ def date_from_iso_format(date_str):
return datetime.date.fromisoformat(date_str)
except ValueError:
raise ParseError(
detail='Invalid date format. Got {}, expected ISO format (YYYY-MM-DD)'.format(
escape(date_str)
)
detail='Invalid date format. Expected ISO format (YYYY-MM-DD)'
)

def filter_timecards(queryset, params={}):
Expand Down
2 changes: 1 addition & 1 deletion tock/hours/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ def test_ReportingPeriodDetailView_escape_invalid_date_404(self):
expect_errors=True
)
self.assertEqual(response.status_code, 400)
self.assertEqual(response.json['detail'], 'Invalid date format. Got "><fish>, expected ISO format (YYYY-MM-DD)')
self.assertEqual(response.json['detail'], 'Invalid date format. Expected ISO format (YYYY-MM-DD)')

def test_ReportingPeriodDetailView_add_submitted_time(self):
"""
Expand Down

0 comments on commit f4750d2

Please sign in to comment.