Selaa lähdekoodia

* Replaced 5 StringReplaces with one StringsReplace

git-svn-id: trunk@17755 -
joost 14 vuotta sitten
vanhempi
commit
092892ee82
1 muutettua tiedostoa jossa 5 lisäystä ja 13 poistoa
  1. 5 13
      packages/fcl-xml/src/htmlelements.pp

+ 5 - 13
packages/fcl-xml/src/htmlelements.pp

@@ -18,7 +18,7 @@ unit htmlelements;
 interface
 interface
 
 
 uses
 uses
-  Classes, SysUtils, DOM, HtmlDefs;
+  Classes, SysUtils, DOM, HtmlDefs, strutils;
 
 
 type
 type
 
 
@@ -135,22 +135,14 @@ implementation
 
 
 function EscapeHTML ( const S : String ) : String;
 function EscapeHTML ( const S : String ) : String;
 begin
 begin
-  Result := StringReplace(s,      '&', '&',  [rfReplaceAll]);
-  Result := StringReplace(Result, '<', '&lt;',   [rfReplaceAll]);
-  Result := StringReplace(Result, '>', '&gt;',   [rfReplaceAll]);
-  Result := StringReplace(Result, '"', '&quot;', [rfReplaceAll]);
-  Result := StringReplace(Result, #39, '&#39;',  [rfReplaceAll]); // ' - &apos; does not work on ie :(
+  // &apos; does not work on all versions of ie, so do not use it.
+  Result := StringsReplace(s,['&','<','>','"',#39],['&amp;','&lt;','&gt;','&quot;','&#39;'],[rfReplaceAll]);
 end;
 end;
 
 
 function UnescapeHTML ( const S : String ) : String;
 function UnescapeHTML ( const S : String ) : String;
 begin
 begin
-  Result := StringReplace(s,      '&lt;',   '<', [rfReplaceAll]);
-  Result := StringReplace(Result, '&gt;',   '>', [rfReplaceAll]);
-  Result := StringReplace(Result, '&quot;', '"', [rfReplaceAll]);
-  Result := StringReplace(Result, '&#39;',  #39, [rfReplaceAll]); // '
-  Result := StringReplace(Result, '&apos;', #39, [rfReplaceAll]); // '
-  Result := StringReplace(Result, '&amp;',  '&', [rfReplaceAll]);
-end; 
+  Result := StringsReplace(result,['&amp;','&lt;','&gt;','&quot;','&apos;','&#39;'],['&','<','>','"',#39,#39],[rfReplaceAll]);
+end;
 
 
 
 
 { THtmlCustomElement }
 { THtmlCustomElement }