Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #18675 -- Fixed was_modified_since with floating-point mtime

Thanks Simon Charette for the patch.
  • Loading branch information...
commit 3cbe686af6b6a3f23a607b2eb7497c55d88e8345 1 parent b3ee80a
@claudep claudep authored
View
2  django/views/static.py
@@ -138,7 +138,7 @@ def was_modified_since(header=None, mtime=0, size=0):
header_len = matches.group(3)
if header_len and int(header_len) != size:
raise ValueError
- if mtime > header_mtime:
+ if int(mtime) > header_mtime:
raise ValueError
except (AttributeError, ValueError, OverflowError):
return True
View
2  tests/regressiontests/views/tests/__init__.py
@@ -7,4 +7,4 @@
from .i18n import JsI18NTests, I18NTests, JsI18NTestsMultiPackage
from .shortcuts import ShortcutTests
from .specials import URLHandling
-from .static import StaticHelperTest, StaticTests
+from .static import StaticHelperTest, StaticUtilsTests, StaticTests
View
16 tests/regressiontests/views/tests/static.py
@@ -2,11 +2,14 @@
import mimetypes
from os import path
+import unittest
from django.conf import settings
from django.conf.urls.static import static
-from django.test import TestCase
from django.http import HttpResponseNotModified
+from django.test import TestCase
+from django.utils.http import http_date
+from django.views.static import was_modified_since
from .. import urls
from ..urls import media_dir
@@ -105,3 +108,14 @@ def setUp(self):
def tearDown(self):
super(StaticHelperTest, self).tearDown()
urls.urlpatterns = self._old_views_urlpatterns
+
+
+class StaticUtilsTests(unittest.TestCase):
+ def test_was_modified_since_fp(self):
+ """
+ Test that a floating point mtime does not disturb was_modified_since.
+ (#18675)
+ """
+ mtime = 1343416141.107817
+ header = http_date(mtime)
+ self.assertFalse(was_modified_since(header, mtime))
Please sign in to comment.
Something went wrong with that request. Please try again.