Mercurial > public > mercurial-scm > hg-stable
diff tests/test-command-template.t @ 28212:d4419c01532b
templatefilters: make json filter be byte-transparent (BC) (issue4926)
This is necessary to preserve filename encoding over JSON. Instead, this
patch inserts "|utf8" where non-ascii local-encoding texts can be passed
to "|json".
See also the commit that introduced "utf8" filter.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 27 Dec 2015 17:59:57 +0900 |
parents | 8ddf893560fa |
children | 7279e0132347 |
line wrap: on
line diff
--- a/tests/test-command-template.t Mon Jan 04 23:05:09 2016 +0900 +++ b/tests/test-command-template.t Sun Dec 27 17:59:57 2015 +0900 @@ -3542,6 +3542,11 @@ hg: parse error: invalid \x escape [255] +json filter should escape HTML tags so that the output can be embedded in hgweb: + + $ hg log -T "{'<foo@example.org>'|json}\n" -R a -l1 + "\u003cfoo@example.org\u003e" + Set up repository for non-ascii encoding tests: $ hg init nonascii @@ -3558,11 +3563,12 @@ $ HGENCODING=ascii hg log -T "{branch|json}\n" -r0 "\u00e9" -json filter should not abort if it can't decode bytes: -(not sure the current behavior is right; we might want to use utf-8b encoding?) +json filter takes input as utf-8b: $ HGENCODING=ascii hg log -T "{'`cat utf-8`'|json}\n" -l1 - "\ufffd\ufffd" + "\u00e9" + $ HGENCODING=ascii hg log -T "{'`cat latin1`'|json}\n" -l1 + "\udce9" utf8 filter: