note 70862 added to function.strip-tags
| From: | anonymous at osu1 dot php dot net | Date: | Wed, 01 Nov 2006 12:52:03 +0000 |
| Subject: | note 70862 added to function.strip-tags | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119293@lists.php.net to get a copy of this message | ||
A different approach to cleaning up HTML would be to first escape all unsafe characters:
& to &
< to <
> to >
then to unescape matching pairs of tags back (e.g.
"<b>hello</b>" => "<b>hello</b>"), if
it is identified safe.
This backwards-approach should be safer because if a tag is not identified correctly, it is, at the
end, in an escaped state.
So if a user enters invalid html, or tags that are unsupported or unwanted, they are shown in plain
text, and not stripped away. This is good, because the characters "<" and
">" might have been used in a different way (e.g. to make a text arrow: "a
<=> b").
This is the case in most forums (apart from the fact that they use "[tag]"-tags instead of
"<tag>"-tags)
----
Server IP: 194.153.94.10
Probable Submitter: 195.176.0.51
----
Manual Page -- http://www.php.net/manual/en/function.strip-tags.php
Edit -- https://master.php.net/note/edit/70862
Del: integrated -- https://master.php.net/note/delete/70862/integrated
Del: useless -- https://master.php.net/note/delete/70862/useless
Del: bad code -- https://master.php.net/note/delete/70862/bad+code
Del: spam -- https://master.php.net/note/delete/70862/spam
Del: non-english -- https://master.php.net/note/delete/70862/non-english
Del: in docs -- https://master.php.net/note/delete/70862/in+docs
Del: other reasons-- https://master.php.net/note/delete/70862
Reject -- https://master.php.net/note/reject/70862
Search -- https://master.php.net/manage/user-notes.php