changeset 39469:1a786fe069b8

hgweb: add error template to json so it won't crash
author Yuya Nishihara <yuya@tcha.org>
date Fri, 07 Sep 2018 22:19:28 +0900
parents 6772cf74ff6f
children 17ca967e9fca
files mercurial/templates/json/map tests/test-hgweb-json.t
diffstat 2 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templates/json/map	Fri Sep 07 22:12:46 2018 +0900
+++ b/mercurial/templates/json/map	Fri Sep 07 22:19:28 2018 +0900
@@ -241,3 +241,6 @@
   "lastchange": {lastchange|json},
   "labels": {labels|json}
   }'
+error = '\{
+  "error": {error|utf8|json}
+  }'
--- a/tests/test-hgweb-json.t	Fri Sep 07 22:12:46 2018 +0900
+++ b/tests/test-hgweb-json.t	Fri Sep 07 22:19:28 2018 +0900
@@ -2183,6 +2183,16 @@
     "topic": "phases"
   }
 
+Error page shouldn't crash
+
+  $ request json-changeset/deadbeef
+  404 Not Found
+  
+  {
+    "error": "unknown revision 'deadbeef'"
+  }
+  [1]
+
 Commit message with Japanese Kanji 'Noh', which ends with '\x5c'
 
   $ echo foo >> da/foo