From ead6d67a689ded8610c51fb62fe68a613a0af6c4 Mon Sep 17 00:00:00 2001
From: Bruno Guillaume <Bruno.Guillaume@loria.fr>
Date: Mon, 22 Jan 2018 22:49:25 +0100
Subject: [PATCH] Fix bug https://gitlab.inria.fr/grew/grew_web/issues/1

---
 src/gd_request.ml | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/gd_request.ml b/src/gd_request.ml
index 0fe0e28..1d94a46 100644
--- a/src/gd_request.ml
+++ b/src/gd_request.ml
@@ -72,6 +72,8 @@ module Request = struct
     | Libgrew.Error msg -> Utils.error uuid msg
     | exc -> Utils.error uuid (sprintf "Unexpected error, please report [%s]" (Printexc.to_string exc))
 
+  let esc s = Str.global_replace (Str.regexp "<") "&lt;" s
+
   (* produce 10 more solutions *)
   let next uuid =
     try
@@ -91,10 +93,10 @@ module Request = struct
           let sent_with_context =
             if !context
             then
-              let prev_sent = try let (_,_,s,_) = corpus.(pos-1) in s^"</br>" with _ -> "" in
-              let next_sent = try let (_,_,s,_) = corpus.(pos+1) in s^"</br>" with _ -> "" in
-              sprintf "%s <font color=\"#FC5235\">%s</font> %s" prev_sent sent next_sent
-            else sprintf "<font color=\"#FC5235\">%s</font>" sent in
+              let prev_sent = try let (_,_,s,_) = corpus.(pos-1) in (esc s)^"</br>" with _ -> "" in
+              let next_sent = try let (_,_,s,_) = corpus.(pos+1) in "</br>"^(esc s) with _ -> "" in
+              sprintf "%s <font color=\"#FC5235\">%s</font> %s" prev_sent (esc sent) next_sent
+            else sprintf "<font color=\"#FC5235\">%s</font>" (esc sent) in
             match kind with
             | Conll -> save_dep ?domain rtl uuid filename text cl.pattern matching graph sent_with_context;
             | Pst -> save_dot ?domain uuid filename text cl.pattern matching graph sent_with_context
-- 
GitLab