Browse Source

* Fix for escaping too much HTML, issue #39203

Michael Van Canneyt 3 years ago
parent
commit
fb6cf854dd
1 changed files with 14 additions and 5 deletions
  1. 14 5
      packages/rtl/browserconsole.pas

+ 14 - 5
packages/rtl/browserconsole.pas

@@ -99,20 +99,29 @@ begin
 end;
 
 
-Procedure WriteConsole(S : JSValue; NewLine : Boolean);
+Function EscapeString(S : String) : String;
 
 Var
-  CL: String;
+  CL : string;
 
 begin
-  CL:=LastLine.InnerHtml;
-  CL:=CL+String(S);
-  cl:=StringReplace(cl,'<','&lt;',[rfReplaceAll]);
+  cl:=StringReplace(S,'<','&lt;',[rfReplaceAll]);
   cl:=StringReplace(cl,'>','&gt;',[rfReplaceAll]);
   cl:=StringReplace(cl,' ','&nbsp;',[rfReplaceAll]);
   cl:=StringReplace(cl,#13#10,'<br>',[rfReplaceAll]);
   cl:=StringReplace(cl,#10,'<br>',[rfReplaceAll]);
   cl:=StringReplace(cl,#13,'<br>',[rfReplaceAll]);
+  Result:=CL;
+end;
+
+Procedure WriteConsole(S : JSValue; NewLine : Boolean);
+
+Var
+  CL: String;
+
+begin
+  CL:=LastLine.InnerHtml;
+  CL:=CL+EscapeString(String(S));
   LastLine.InnerHtml:=CL;
   if NewLine then
     begin