# HG changeset patch # User Matt Mackall # Date 1405359885 18000 # Node ID 829f2dd99f5c77f593cf8e7a922c977dcd88d0da # Parent 1eda3e55684531a1ebd564d8146e8a5f6f4ffcfa templates: escape NUL bytes in jsonescape (issue4303) It's currently possible for various fields to contain NUL bytes, which are disallowed in JSON. diff -r 1eda3e556845 -r 829f2dd99f5c mercurial/templatefilters.py --- a/mercurial/templatefilters.py Thu Jul 03 10:48:37 2014 +0100 +++ b/mercurial/templatefilters.py Mon Jul 14 12:44:45 2014 -0500 @@ -215,7 +215,7 @@ _escapes = [ ('\\', '\\\\'), ('"', '\\"'), ('\t', '\\t'), ('\n', '\\n'), ('\r', '\\r'), ('\f', '\\f'), ('\b', '\\b'), - ('<', '\\u003c'), ('>', '\\u003e') + ('<', '\\u003c'), ('>', '\\u003e'), ('\0', '\\u0000') ] def jsonescape(s): diff -r 1eda3e556845 -r 829f2dd99f5c tests/test-hgweb-commands.t --- a/tests/test-hgweb-commands.t Thu Jul 03 10:48:37 2014 +0100 +++ b/tests/test-hgweb-commands.t Mon Jul 14 12:44:45 2014 -0500 @@ -1436,7 +1436,7 @@