Re: htmlspecialchars() and HTML code

From: Date: Fri, 08 Aug 2003 16:15:01 +0000
Subject: Re: htmlspecialchars() and HTML code
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-158878@lists.php.net to get a copy of this message
Thaddeus J. Quintin wrote:
CPT John W. Holmes wrote: --<SNIP>-- Try this: <textarea name="text">This is &lt;some&gt; text</textarea> If you submit that "text" and then print $_REQUEST['text'], you'll see that you have This is <some> text --<SNIP>-- Ok, but that only makes me realize the further extent of the problem. If the HTML file that they upload has '&lt;' or '&gt;' entities, then these characters will be displayed in the text area as '<' and '>' symbols. So when the text is submitted from the textarea, all of the user's HTML entities will have been destroyed. Any thoughts on this problem?
Yep, of course. :) If there is a &lt; in the file, when you apply htmlentities(), it'll come out in the HTML source as &amp;lt; and appear as &lt; in the rendered <textarea>. So... it's not an issue. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ PHP|Architect: A magazine for PHP Professionals – www.phparch.com

« previous php.general (#158878) next »