# HG changeset patch
# User Yuya Nishihara <y...@tcha.org>
# Date 1536326368 -32400
#      Fri Sep 07 22:19:28 2018 +0900
# Node ID 90fe6481af4fd42def159f8e501612f305979822
# Parent  cd0c58017ae949408c1e746c9c81ca6847591b3c
hgweb: add error template to json so it won't crash

diff --git a/mercurial/templates/json/map b/mercurial/templates/json/map
--- a/mercurial/templates/json/map
+++ b/mercurial/templates/json/map
@@ -241,3 +241,6 @@ indexentry = '\{
   "lastchange": {lastchange|json},
   "labels": {labels|json}
   }'
+error = '\{
+  "error": {error|utf8|json}
+  }'
diff --git a/tests/test-hgweb-json.t b/tests/test-hgweb-json.t
--- a/tests/test-hgweb-json.t
+++ b/tests/test-hgweb-json.t
@@ -2183,6 +2183,16 @@ help/{topic} shows an individual help to
     "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
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to