From af1135e7e7c1a8d572e2fe152dad55d84b42b7cb Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Mon, 18 Apr 2016 16:48:49 +0200 Subject: Fix problem with stylesheet tags getting escaped OTP-13536 --- lib/common_test/src/ct_logs.erl | 46 ++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'lib/common_test/src') diff --git a/lib/common_test/src/ct_logs.erl b/lib/common_test/src/ct_logs.erl index 84948a269b..e550112aa5 100644 --- a/lib/common_test/src/ct_logs.erl +++ b/lib/common_test/src/ct_logs.erl @@ -793,7 +793,7 @@ logger_loop(State) -> %% make sure no IO for this test case from the %% CT logger gets rejected test_server:permit_io(GL, self()), - print_style(GL, State#logger_state.stylesheet), + print_style(GL,GL,State#logger_state.stylesheet), set_evmgr_gl(GL), TCGLs = add_tc_gl(TCPid,GL,State), if not RefreshLog -> @@ -1106,26 +1106,27 @@ open_ctlog(MiscIoName) -> "View I/O logged after the test run\n\n", [MiscIoName,MiscIoName]), - print_style(Fd,undefined), + print_style(Fd,group_leader(),undefined), io:format(Fd, xhtml("

Progress Log

\n
\n",
 		    "
\n

PROGRESS LOG

\n
\n"), []),
     Fd.
 
-print_style(Fd,undefined) ->
+print_style(Fd,GL,undefined) ->
     case basic_html() of
 	true ->
-	    io:format(Fd,
-		      "\n",
-		      []);
+	    Style = "\n",
+	    if Fd == GL -> io:format(["$tc_html",Style], []);
+	       true     -> io:format(Fd, Style, [])
+	    end;
 	_ ->
 	    ok
     end;
 
-print_style(Fd,StyleSheet) ->
+print_style(Fd,GL,StyleSheet) ->
     case file:read_file(StyleSheet) of
 	{ok,Bin} ->
 	    Str = b2s(Bin,encoding(StyleSheet)),
@@ -1138,23 +1139,30 @@ print_style(Fd,StyleSheet) ->
 		       N1 -> N1
 		   end,
 	    if (Pos0 == 0) and (Pos1 /= 0) ->
-		    print_style_error(Fd,StyleSheet,missing_style_start_tag);
+		    print_style_error(Fd,GL,StyleSheet,missing_style_start_tag);
 	       (Pos0 /= 0) and (Pos1 == 0) ->
-		    print_style_error(Fd,StyleSheet,missing_style_end_tag);
+		    print_style_error(Fd,GL,StyleSheet,missing_style_end_tag);
 	       Pos0 /= 0 ->
 		    Style = string:sub_string(Str,Pos0,Pos1+7),
-		    io:format(Fd,"~ts\n",[Style]);
+		    if Fd == GL -> io:format(Fd,["$tc_html","~ts\n"],[Style]);
+		       true     -> io:format(Fd,"~ts\n",[Style])
+		    end;
 	       Pos0 == 0 ->
-		    io:format(Fd,"\n",[Str])
+		    if Fd == GL -> io:format(Fd,["$tc_html","\n"],[Str]);
+		       true     -> io:format(Fd,"\n",[Str])
+		    end
 	    end;
 	{error,Reason} ->
-	    print_style_error(Fd,StyleSheet,Reason)  
+	    print_style_error(Fd,GL,StyleSheet,Reason)  
     end.
 
-print_style_error(Fd,StyleSheet,Reason) ->
-    io:format(Fd,"\n\n",
-	      [StyleSheet,Reason]),
-    print_style(Fd,undefined).    
+print_style_error(Fd,GL,StyleSheet,Reason) ->
+    IO = io_lib:format("\n\n",
+		       [StyleSheet,Reason]),
+    if Fd == GL -> io:format(Fd,["$tc_html",IO],[]);
+       true     -> io:format(Fd,IO,[])
+    end,
+    print_style(Fd,GL,undefined).    
 
 close_ctlog(Fd) ->
     io:format(Fd, "\n
\n", []), -- cgit v1.2.3