Skip to content
This repository has been archived by the owner on Dec 28, 2020. It is now read-only.

Commit

Permalink
Try to properly return a 400 when a bad date is submitted to a timegate
Browse files Browse the repository at this point in the history
  • Loading branch information
palewire committed Dec 1, 2015
1 parent 050485d commit 831b993
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions memento/timegate/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class MementoDetailView(DetailView):
* timegate_pattern: The name of the URL pattern for this site's TimeGate
that, given the original url, is able to reverse to return the
location of the url where a datetime can be submitted to find
the closest mementos for this resource.
the closest mementos for this resource.
* get_original_url: A method that, given the object being rendered
by the view, will return the original URL of the archived resource.
Expand Down Expand Up @@ -122,7 +122,10 @@ def parse_datetime(self, request):
return None

# Verify that the Accept-Datetime header is valid
dt = dateparser(request.META.get("HTTP_ACCEPT_DATETIME"))
try:
dt = dateparser(request.META.get("HTTP_ACCEPT_DATETIME"))
except ValueError:
dt = None
if not dt:
return HttpResponse(
_("Bad request (400): Accept-Datetime header is malformed"),
Expand Down

0 comments on commit 831b993

Please sign in to comment.