json: pass formatting options recursively
authorYuya Nishihara <yuya@tcha.org>
Fri, 09 Jun 2017 21:33:15 +0900
changeset 32743 f924dd043974
parent 32742 08d0892c93d8
child 32744 33b7283a3828
json: pass formatting options recursively This bug was introduced in 654e9a1c8a6c. It's okay to escape <>, but is unnecessary for command output.
mercurial/templatefilters.py
tests/test-obsolete.t
--- a/mercurial/templatefilters.py	Sun Apr 23 13:40:18 2017 +0900
+++ b/mercurial/templatefilters.py	Fri Jun 09 21:33:15 2017 +0900
@@ -234,11 +234,12 @@
     elif isinstance(obj, bytes):
         return '"%s"' % encoding.jsonescape(obj, paranoid=paranoid)
     elif util.safehasattr(obj, 'keys'):
-        out = ['"%s": %s' % (encoding.jsonescape(k, paranoid=paranoid), json(v))
+        out = ['"%s": %s' % (encoding.jsonescape(k, paranoid=paranoid),
+                             json(v, paranoid))
                for k, v in sorted(obj.iteritems())]
         return '{' + ', '.join(out) + '}'
     elif util.safehasattr(obj, '__iter__'):
-        out = [json(i) for i in obj]
+        out = [json(i, paranoid) for i in obj]
         return '[' + ', '.join(out) + ']'
     else:
         raise TypeError('cannot encode type %s' % obj.__class__.__name__)
--- a/tests/test-obsolete.t	Sun Apr 23 13:40:18 2017 +0900
+++ b/tests/test-obsolete.t	Fri Jun 09 21:33:15 2017 +0900
@@ -739,7 +739,7 @@
    {
     "date": *, (glob)
     "flag": 0,
-    "metadata": {"user": "test \u003ctest@example.net\u003e"},
+    "metadata": {"user": "test <test@example.net>"},
     "precnode": "cda648ca50f50482b7055c0b0c4c117bba6733d9",
     "succnodes": ["3de5eca88c00aa039da7399a220f4a5221faa585"]
    }