hgweb: replace a trivial file read with the `util` function
authorMatt Harbison <matt_harbison@yahoo.com>
Tue, 17 Dec 2024 01:10:28 -0500
changeset 52576 08612516d436
parent 52575 f106d0e629e5
child 52577 a58f7f809fa5
hgweb: replace a trivial file read with the `util` function Not sure why there's an `os.stat()` here- I'd expect any errors that it might hit to also be hit by attempting to open the file in read mode. It goes all the way back to a9343f9d7365 in 2006, and mentions making things more secure, so I'll leave it be for now.
mercurial/hgweb/common.py
--- a/mercurial/hgweb/common.py	Tue Dec 17 01:00:59 2024 -0500
+++ b/mercurial/hgweb/common.py	Tue Dec 17 01:10:28 2024 -0500
@@ -219,8 +219,7 @@
     path = os.path.join(directory, fpath)
     try:
         os.stat(path)
-        with open(path, 'rb') as fh:
-            data = fh.read()
+        data = util.readfile(path)
     except TypeError:
         raise ErrorResponse(HTTP_SERVER_ERROR, b'illegal filename')
     except OSError as err: