Bug 5699 - hg log -T '{ui}' exposes internal state
Summary: hg log -T '{ui}' exposes internal state
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: templater (show other bugs)
Version: default branch
Hardware: All All
: wish bug
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-05 04:18 UTC by Jun Wu
Modified: 2018-01-04 00:00 UTC (History)
2 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jun Wu 2017-10-05 04:18 UTC
Internal state could be observed by template keywords:

  [quark@x1c hg]$ ./hg log -r . -T '{ui}\n'
  <mercurial.ui.ui object at 0x7f55008cedd0>

"{ctx}", "{repo}", "{templ}", "{revcache}" are probably also unwanted.

It seems we use a single map to store both keyword functions and raw data. It'd be nice if we can separate data from keyword functions.
Comment 1 Yuya Nishihara 2017-10-05 08:49 UTC
It's one of the templater mess.
Comment 2 HG Bot 2017-12-27 00:55 UTC
Fixed by https://mercurial-scm.org/repo/hg/rev/d6cfa722b044
Yuya Nishihara <yuya@tcha.org>
templater: look up mapping table through template engine

These functions are stub for symbol/resource separation. This series is
intended to address the following problems:

 a) internal data may be exposed to user (issue5699)
 b) defaults['repo'] (a repository name) will conflict with mapping['repo']
    (a repo object) in hgweb

(please test the fix)
Comment 3 HG Bot 2017-12-27 00:55 UTC
Fixed by https://mercurial-scm.org/repo/hg/rev/a33be093ec62
Yuya Nishihara <yuya@tcha.org>
templater: look up symbols/resources as if they were separated (issue5699)

It wouldn't be easy to split the mapping dict into (symbols, resources). This
patch instead rejects invalid lookup taking resources.keys() as source of
truth.

The doctest is updated since mapping['repo'] is now reserved for a repo
object.

(please test the fix)
Comment 4 Bugzilla 2018-01-04 00:00 UTC
Bug was set to TESTING for 7 days, resolving