[PATCH] statichttprepo: abort if opener mode is 'r+' or 'rb+'

Adrian Buehlmann adrian at cadifra.com
Fri Mar 4 07:26:28 CST 2011


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1297988341 -3600
# Node ID ce3e6fd18d43c4a3facf250881d4268145c468c7
# Parent  5f69af0d2fb3790f6d84a237d22e86498bc1d0fb
statichttprepo: abort if opener mode is 'r+' or 'rb+'

The old version of the check failed to catch
modifying modes 'r+' and 'rb+'.

diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py
--- a/mercurial/statichttprepo.py
+++ b/mercurial/statichttprepo.py
@@ -71,7 +71,7 @@ def build_opener(ui, authinfo):
         """return a function that opens files over http"""
         p = base
         def o(path, mode="r", atomictemp=None):
-            if 'a' in mode or 'w' in mode:
+            if mode not in ('r', 'rb'):
                 raise IOError('Permission denied')
             f = "/".join((p, urllib.quote(path)))
             return httprangereader(f, urlopener)


More information about the Mercurial-devel mailing list