Skip to content

Commit a82c39a

Browse files
committed
Merge branch 'feature/issue#17-fix-html-safe-chars' into develop
2 parents 620eebd + 6fea1b8 commit a82c39a

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

Src/UConsts.pas

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ interface
2929
CR = #13; // carriage return character
3030
SUB = #26; // ASCII SUB character
3131
ESC = #27; // escape character
32+
3233
SINGLEQUOTE = ''''; // single quote character
3334
DOUBLEQUOTE = '"'; // double quote character
35+
AMPERSAND = '&'; // ampersand character
36+
GT = '>'; // greater-than / closing angle bracket character
37+
LT = '<'; // less-than / opening angle bracket character
3438

3539
CRLF = CR + LF; // carriage return followed by line feed
3640
EOL = CRLF; // end of line character sequence for Windows systems

Src/UHTMLUtils.pas

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -227,18 +227,12 @@ class function THTML.Entities(const Text: string): string;
227227
for Ch in Text do
228228
begin
229229
case Ch of
230-
'<':
231-
SB.Append('&lt;');
232-
'>':
233-
SB.Append('&gt;');
234-
'&':
235-
SB.Append('&amp;');
236-
DOUBLEQUOTE:
237-
SB.Append('&quot;');
238-
#0..#9, #11, #12, #14..#31:
239-
SB.Append('&#' + IntToStr(Ord(Ch)) + ';')
240-
else
241-
SB.Append(Ch);
230+
LT: SB.Append('&lt;');
231+
GT: SB.Append('&gt;');
232+
SINGLEQUOTE: SB.Append('&apos;');
233+
DOUBLEQUOTE: SB.Append('&quot;');
234+
AMPERSAND: SB.Append('&amp;');
235+
else SB.Append(Ch);
242236
end;
243237
end;
244238
Result := SB.ToString;

0 commit comments

Comments
 (0)