|
@@ -128,8 +128,30 @@ type
|
|
|
procedure WriteToStream (const aStream : TStream); override;
|
|
|
end;
|
|
|
|
|
|
+function EscapeHTML(const s : String) : String;
|
|
|
+function UnescapeHTML(const s : String) : String;
|
|
|
+
|
|
|
implementation
|
|
|
|
|
|
+function EscapeHTML ( const S : String ) : String;
|
|
|
+begin
|
|
|
+ Result := StringReplace(s, '&', '&', [rfReplaceAll]);
|
|
|
+ Result := StringReplace(Result, '<', '<', [rfReplaceAll]);
|
|
|
+ Result := StringReplace(Result, '>', '>', [rfReplaceAll]);
|
|
|
+ Result := StringReplace(Result, '"', '"', [rfReplaceAll]);
|
|
|
+ Result := StringReplace(Result, #39, ''', [rfReplaceAll]); // ' - ' does not work on ie :(
|
|
|
+end;
|
|
|
+
|
|
|
+function UnescapeHTML ( const S : String ) : String;
|
|
|
+begin
|
|
|
+ Result := StringReplace(s, '<', '<', [rfReplaceAll]);
|
|
|
+ Result := StringReplace(Result, '>', '>', [rfReplaceAll]);
|
|
|
+ Result := StringReplace(Result, '"', '"', [rfReplaceAll]);
|
|
|
+ Result := StringReplace(Result, ''', #39, [rfReplaceAll]); // '
|
|
|
+ Result := StringReplace(Result, ''', #39, [rfReplaceAll]); // '
|
|
|
+ Result := StringReplace(Result, '&', '&', [rfReplaceAll]);
|
|
|
+end;
|
|
|
+
|
|
|
|
|
|
{ THtmlCustomElement }
|
|
|
|
|
@@ -201,8 +223,7 @@ end;
|
|
|
|
|
|
function THtmlCustomElement.EscapeString(s: string): string;
|
|
|
begin
|
|
|
- result := s;
|
|
|
- //TODO: Needs to convert all the special signs to their html names ("<" has to be "<" etc.)
|
|
|
+ result := EscapeHTML(s);
|
|
|
end;
|
|
|
|
|
|
constructor THtmlCustomElement.create(AOwner: TDOMDocument);
|