mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-30 12:20:19 +02:00
* Patch from Ido Kanner to add HTMLEncode and HTMLDecode
git-svn-id: trunk@17718 -
This commit is contained in:
parent
6b42ee69a9
commit
8f49adf3c8
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user