##// END OF EJS Templates
config: honour the trusted flag in ui.configbytes
Martijn Pieters -
r31472:75e4bae5 default
parent child Browse files
Show More
@@ -542,7 +542,7 class ui(object):
542 ConfigError: foo.invalid is not a byte quantity ('somevalue')
542 ConfigError: foo.invalid is not a byte quantity ('somevalue')
543 """
543 """
544
544
545 value = self.config(section, name)
545 value = self.config(section, name, None, untrusted)
546 if value is None:
546 if value is None:
547 if not isinstance(default, str):
547 if not isinstance(default, str):
548 return default
548 return default
@@ -201,3 +201,41 try:
201 testui(debug=True, silent=True)
201 testui(debug=True, silent=True)
202 except error.ParseError as inst:
202 except error.ParseError as inst:
203 print(inst)
203 print(inst)
204
205 print()
206 print('# access typed information')
207 with open('.hg/hgrc', 'w') as f:
208 f.write('''\
209 [foo]
210 sub=main
211 sub:one=one
212 sub:two=two
213 path=monty/python
214 bool=true
215 int=42
216 bytes=81mb
217 list=spam,ham,eggs
218 ''')
219 u = testui(user='abc', group='def', cuser='foo', silent=True)
220 print('# suboptions, trusted and untrusted')
221 trusted = u.configsuboptions('foo', 'sub')
222 untrusted = u.configsuboptions('foo', 'sub', untrusted=True)
223 print(
224 (trusted[0], sorted(trusted[1].items())),
225 (untrusted[0], sorted(untrusted[1].items())))
226 print('# path, trusted and untrusted')
227 print(u.configpath('foo', 'path'), u.configpath('foo', 'path', untrusted=True))
228 print('# bool, trusted and untrusted')
229 print(u.configbool('foo', 'bool'), u.configbool('foo', 'bool', untrusted=True))
230 print('# int, trusted and untrusted')
231 print(
232 u.configint('foo', 'int', 0),
233 u.configint('foo', 'int', 0, untrusted=True))
234 print('# bytes, trusted and untrusted')
235 print(
236 u.configbytes('foo', 'bytes', 0),
237 u.configbytes('foo', 'bytes', 0, untrusted=True))
238 print('# list, trusted and untrusted')
239 print(
240 u.configlist('foo', 'list', []),
241 u.configlist('foo', 'list', [], untrusted=True))
@@ -177,3 +177,19 not trusting file .hg/hgrc from untruste
177 ('foo', '.hg/hgrc:1')
177 ('foo', '.hg/hgrc:1')
178 # same user, same group
178 # same user, same group
179 ('foo', '.hg/hgrc:1')
179 ('foo', '.hg/hgrc:1')
180
181 # access typed information
182 # different user, different group
183 not trusting file .hg/hgrc from untrusted user abc, group def
184 # suboptions, trusted and untrusted
185 (None, []) ('main', [('one', 'one'), ('two', 'two')])
186 # path, trusted and untrusted
187 None .hg/monty/python
188 # bool, trusted and untrusted
189 False True
190 # int, trusted and untrusted
191 0 42
192 # bytes, trusted and untrusted
193 0 84934656
194 # list, trusted and untrusted
195 [] ['spam', 'ham', 'eggs']
General Comments 0
You need to be logged in to leave comments. Login now