diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -542,7 +542,7 @@ class ui(object): ConfigError: foo.invalid is not a byte quantity ('somevalue') """ - value = self.config(section, name) + value = self.config(section, name, None, untrusted) if value is None: if not isinstance(default, str): return default diff --git a/tests/test-trusted.py b/tests/test-trusted.py --- a/tests/test-trusted.py +++ b/tests/test-trusted.py @@ -201,3 +201,41 @@ try: testui(debug=True, silent=True) except error.ParseError as inst: print(inst) + +print() +print('# access typed information') +with open('.hg/hgrc', 'w') as f: + f.write('''\ +[foo] +sub=main +sub:one=one +sub:two=two +path=monty/python +bool=true +int=42 +bytes=81mb +list=spam,ham,eggs +''') +u = testui(user='abc', group='def', cuser='foo', silent=True) +print('# suboptions, trusted and untrusted') +trusted = u.configsuboptions('foo', 'sub') +untrusted = u.configsuboptions('foo', 'sub', untrusted=True) +print( + (trusted[0], sorted(trusted[1].items())), + (untrusted[0], sorted(untrusted[1].items()))) +print('# path, trusted and untrusted') +print(u.configpath('foo', 'path'), u.configpath('foo', 'path', untrusted=True)) +print('# bool, trusted and untrusted') +print(u.configbool('foo', 'bool'), u.configbool('foo', 'bool', untrusted=True)) +print('# int, trusted and untrusted') +print( + u.configint('foo', 'int', 0), + u.configint('foo', 'int', 0, untrusted=True)) +print('# bytes, trusted and untrusted') +print( + u.configbytes('foo', 'bytes', 0), + u.configbytes('foo', 'bytes', 0, untrusted=True)) +print('# list, trusted and untrusted') +print( + u.configlist('foo', 'list', []), + u.configlist('foo', 'list', [], untrusted=True)) diff --git a/tests/test-trusted.py.out b/tests/test-trusted.py.out --- a/tests/test-trusted.py.out +++ b/tests/test-trusted.py.out @@ -177,3 +177,19 @@ not trusting file .hg/hgrc from untruste ('foo', '.hg/hgrc:1') # same user, same group ('foo', '.hg/hgrc:1') + +# access typed information +# different user, different group +not trusting file .hg/hgrc from untrusted user abc, group def +# suboptions, trusted and untrusted +(None, []) ('main', [('one', 'one'), ('two', 'two')]) +# path, trusted and untrusted +None .hg/monty/python +# bool, trusted and untrusted +False True +# int, trusted and untrusted +0 42 +# bytes, trusted and untrusted +0 84934656 +# list, trusted and untrusted +[] ['spam', 'ham', 'eggs']