Created attachment 1778 [details] Part of the source web page with invalid charachters. Mercurial 3.0.2 on Windows with TortoiseHg 3.0.2, Python 2.7.6 and also: Mercurial 3.0.2 on Linux Ubuntu 12.04. Server Version: Apache/2.2.22 (Ubuntu) mod_wsgi/3.3 Python/2.7.3 Other modules: Phusion_Passenger/4.0.3 PHP/5.3.10-1ubuntu3.10 with Suhosin-Patch When I try to browse a repository of mine, for some branches the name has several unknown charachters/question marks at the beginning, thus causing also the error: "Error: SyntaxError: JSON.parse: bad control character in string literal at line 1 column 133 of the JSON data". at the next AJAX request, scrolling the page from the point the branch "with the invalid chars" appears. Stripping the involved branches in a local clone lets the hgweb graph page work correctly. The same charachters appear to be be present in our Redmine repository interface (accesses the same repository), but only in the links to the involved branches. Attached a part of the script in the web source page with the involved charachters (I have changed personal data).
I've tryed changing repository encoding in the hgweb settings file, but this does not seem to be related to that. Please suggest me how to give more informations on the error if necessary.
What is the output of 'hg branches'?
On Windows: default 1582:05a400c1987b 8.78.13.J 1273:15a2e678ddfa 8.74.10.Z.20131122 1227:eb884c7cc1d5 8.76.12.12149RTL 1095:21370edc496d 8.76.31.20130912 1079:060bcaa31de4 8.76.27 1042:b89b5ca9dae6 patch_messaggiErrore 1581:0d7d4c2ae514 (inactive) Integ_Compl_NTarat 1536:28e5f87f8a8e (inactive) On Linux (SSH console via Putty): default 1580:05a400c1987b 8.78.13.J 1271:15a2e678ddfa 8.74.10.Z.20131122 1225:eb884c7cc1d5 8.76.12.12149RTL 1095:21370edc496d 8.76.31.20130912 1079:060bcaa31de4 8.76.27 1042:b89b5ca9dae6 Integ_Compl_NTarat 1534:28e5f87f8a8e (inactive)
Integ_Compl_NTarat 1536:28e5f87f8a8e (inactive) is the branch with the problem. Didn't notice that on Windows there are spaces before the name. Pretty sure was not inserted like so.
Looks like your branch name got prepended with 8 null bytes... and while Mercurial is happy to accept any valid UTF-8 you give it, JSON doesn't like null bytes. Try again on Linux with: $ hg branches | hexdump -C This is almost certainly a sign of a memory glitch on one of your machines. Does the machine that made the commit have ECC memory?
I can confirm that there are 8 null chars before the name: 00000370 69 76 65 29 0a 00 00 00 00 00 00 00 00 49 6e 74 |ive).........Int| The machine of the developer that did work on that branch is quite old and does not have ECC memory.
Fixed by http://selenic.com/repo/hg/rev/829f2dd99f5c Matt Mackall <mpm@selenic.com> templates: escape NUL bytes in jsonescape (issue4303) It's currently possible for various fields to contain NUL bytes, which are disallowed in JSON. (please test the fix)
Replaced templatefilters.py with the fixed one, works correctly, no JSON errors.
Shiny.