jaymc Posted October 16, 2006 Share Posted October 16, 2006 I have a profile system on my website which allows members to fill in fields with dataFor example[b]First name = Jamie[/b]But, what happens when you get a scripty who comes along and does this[b]First name = <? echo "HI"; ?>[/b]It screws up the page... I need a way to stop it from parsingI have found a tag called [b]<xmp> [/b] which does actually work for both HTML and PHP suprisinglyIm just wondering if this is the proper way to go about protecting my site from code injection.If it is, do I have to wrap <xmp></xmp> around any dynamic data a member can submitThanks Quote Link to comment https://forums.phpfreaks.com/topic/24159-stop-parsing/ Share on other sites More sharing options...
trq Posted October 16, 2006 Share Posted October 16, 2006 First name = <? echo "HI"; ?> should not effect your page unless you are using [url=http://php.net/eval]eval[/url] in some evil way.In any case, just strip unwanted chars from the string. Quote Link to comment https://forums.phpfreaks.com/topic/24159-stop-parsing/#findComment-109793 Share on other sites More sharing options...
jaymc Posted October 17, 2006 Author Share Posted October 17, 2006 Im not using eval, but it is still causing problemsSo, the professional way to go about this is to basically tostr_replace() any occurances of [b]<? <?php?>[/b] Quote Link to comment https://forums.phpfreaks.com/topic/24159-stop-parsing/#findComment-109802 Share on other sites More sharing options...
printf Posted October 17, 2006 Share Posted October 17, 2006 Instead of removing stuff, just make it safe![code]htmlentities();// orhtmlspecialchars();[/code]me! Quote Link to comment https://forums.phpfreaks.com/topic/24159-stop-parsing/#findComment-109806 Share on other sites More sharing options...
jaymc Posted October 17, 2006 Author Share Posted October 17, 2006 So basically put that when ever echoing out any piece of data that is coming from the users fields? Quote Link to comment https://forums.phpfreaks.com/topic/24159-stop-parsing/#findComment-109816 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.