From 7152cb74a9ddf74b22dae4fb767eb96052122756 Mon Sep 17 00:00:00 2001
From: Fang <git@fang.io>
Date: Fri, 8 May 2020 19:50:31 +0200
Subject: [PATCH] chat: virtualize message-to-json conversion

Bad `@t` text might crash and fully halt the json conversion, preventing any
data from being delivered to the frontend.

Fixes #2878.
---
 pkg/arvo/lib/chat-json.hoon | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/pkg/arvo/lib/chat-json.hoon b/pkg/arvo/lib/chat-json.hoon
index 349d3de887..558c444c3b 100644
--- a/pkg/arvo/lib/chat-json.hoon
+++ b/pkg/arvo/lib/chat-json.hoon
@@ -41,9 +41,16 @@
   (fall ((ot output+(ar dank) ~) a) ~)
 ::
 ++  lett
+  =,  enjs:format
   |=  =letter
   ^-  json
-  =,  enjs:format
+  =;  result=(each json tang)
+    ?-  -.result
+      %&  p.result
+      %|  (frond %text s+'[[json rendering error]]')
+    ==
+  %-  mule
+  |.
   ?-  -.letter
       %text
     (frond %text s+text.letter)