changeset 52602:08612516d436

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.
author Matt Harbison <matt_harbison@yahoo.com>
date Tue, 17 Dec 2024 01:10:28 -0500
parents f106d0e629e5
children a58f7f809fa5
files mercurial/hgweb/common.py
diffstat 1 files changed, 1 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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: