##// END OF EJS Templates
templatefilters: make json filter handle multibyte characters correctly...
Yuya Nishihara -
r11765:aff419e2 stable
parent child Browse files
Show More
@@ -156,9 +156,10 b' def json(obj):'
156 156 elif isinstance(obj, int) or isinstance(obj, float):
157 157 return str(obj)
158 158 elif isinstance(obj, str):
159 return '"%s"' % jsonescape(obj)
159 u = unicode(obj, encoding.encoding, 'replace')
160 return '"%s"' % jsonescape(u).encode('utf-8')
160 161 elif isinstance(obj, unicode):
161 return json(obj.encode('utf-8'))
162 return '"%s"' % jsonescape(obj).encode('utf-8')
162 163 elif hasattr(obj, 'keys'):
163 164 out = []
164 165 for k, v in obj.iteritems():
@@ -60,5 +60,19 b' echo % failing unbundle, requires POST r'
60 60 echo % Static files
61 61 "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/static/style.css'
62 62
63 echo % Stop and restart with HGENCODING=cp932
64 "$TESTDIR/killdaemons.py"
65 HGENCODING=cp932 hg serve --config server.uncompressed=False -n test \
66 -p $HGPORT -d --pid-file=hg.pid -E errors.log
67 cat hg.pid >> $DAEMON_PIDS
68
69 # commit message with Japanese Kanji 'Noh', which ends with '\x5c'
70 echo foo >> foo
71 HGENCODING=cp932 hg ci -m `python -c 'print("\x94\x5c")'`
72
73 echo % Graph json escape of multibyte character
74 "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/graph/' \
75 | grep '^var data ='
76
63 77 echo % ERRORS ENCOUNTERED
64 78 cat errors.log
@@ -982,4 +982,7 b' ul#graphnodes li .info {'
982 982 position: relative;
983 983 top: -1px;
984 984 }
985 % Stop and restart with HGENCODING=cp932
986 % Graph json escape of multibyte character
987 var data = [["40b4d6888e92", [0, 1], [[0, 0, 1]], "能", "test", "1970-01-01", ["stable", true], ["tip"]], ["1d22e65f027e", [0, 1], [[0, 0, 1]], "branch", "test", "1970-01-01", ["stable", false], []], ["a4f92ed23982", [0, 1], [[0, 0, 1]], "Added tag 1.0 for changeset 2ef0ac749a14", "test", "1970-01-01", ["default", true], []], ["2ef0ac749a14", [0, 1], [], "base", "test", "1970-01-01", ["default", false], ["1.0"]]];
985 988 % ERRORS ENCOUNTERED
General Comments 0
You need to be logged in to leave comments. Login now