From: Mike DePalatis Date: Sat, 23 Nov 2019 19:42:56 +0000 (-0700) Subject: web: Update hashing algorithm in StaticFileHandler (#2778) X-Git-Tag: v6.1.0b1~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2054f476cca2975caf80268da96ef3f7f3be4e88;p=thirdparty%2Ftornado.git web: Update hashing algorithm in StaticFileHandler (#2778) Addresses #2776. --- diff --git a/tornado/test/web_test.py b/tornado/test/web_test.py index 7c1322e0b..9e6c15bf5 100644 --- a/tornado/test/web_test.py +++ b/tornado/test/web_test.py @@ -1052,9 +1052,12 @@ class ErrorResponseTest(WebTestCase): class StaticFileTest(WebTestCase): - # The expected MD5 hash of robots.txt, used in tests that call + # The expected SHA-512 hash of robots.txt, used in tests that call # StaticFileHandler.get_version - robots_txt_hash = b"f71d20196d4caf35b6a670db8c70b03d" + robots_txt_hash = ( + b"63a36e950e134b5217e33c763e88840c10a07d80e6057d92b9ac97508de7fb1f" + b"a6f0e9b7531e169657165ea764e8963399cb6d921ffe6078425aaafe54c04563" + ) static_dir = os.path.join(os.path.dirname(__file__), "static") def get_handlers(self): diff --git a/tornado/web.py b/tornado/web.py index 3fc99fb8d..a3a8f61cf 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -2822,12 +2822,12 @@ class StaticFileHandler(RequestHandler): """Returns a version string for the resource at the given path. This class method may be overridden by subclasses. The - default implementation is a hash of the file's contents. + default implementation is a SHA-512 hash of the file's contents. .. versionadded:: 3.1 """ data = cls.get_content(abspath) - hasher = hashlib.md5() + hasher = hashlib.sha512() if isinstance(data, bytes): hasher.update(data) else: