[Bug 4933] New: JSON template filter operates on local encoding

mercurial-bugs at selenic.com mercurial-bugs at selenic.com
Tue Nov 3 22:18:00 UTC 2015


https://bz.mercurial-scm.org/show_bug.cgi?id=4933

            Bug ID: 4933
           Summary: JSON template filter operates on local encoding
           Product: Mercurial
           Version: 3.6
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: bug
          Priority: wish
         Component: Mercurial
          Assignee: bugzilla at selenic.com
          Reporter: gregory.szorc at gmail.com
                CC: mercurial-devel at selenic.com

If an encoding.localstr is passed to templatefilters.json(), the value decoded
by the locally set encoding will be used instead of the original, unmodified
byte sequence:

    elif isinstance(obj, str):
        u = unicode(obj, encoding.encoding, 'replace')
        return '"%s"' % jsonescape(u)

I think this is a bug because the JSON spec says that output SHALL be encoded
in UTF-8, UTF-16, or UTF-32 (https://tools.ietf.org/html/rfc7159#section-8.1).
Since the encoding is defined by JSON itself, I think we should be using the
raw byte sequences instead of the decoded value from the locally-set encoding.

If servers aren't sanely configured to use a Unicode encoding, the current
behavior could result in unknown code points getting converted to literal "?"
in the JSON output.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Mercurial-devel mailing list