Jump to content

escaping outputs


ibolui

Recommended Posts

hi, i just read that for security purposes, i should escaped my $output before echoing the values. and the method is to use htmlentities.

 

however if the $output is a html text, for example, $output = "A 'quote' is <b>bold</b>";

and i wish to retain the < b > instead of becoming <b>

what should i do?

 

if i am to echo ANY unescaped output to a flash app frontend, will there be security issues  ???

Link to comment
https://forums.phpfreaks.com/topic/123228-escaping-outputs/
Share on other sites

What you need is token replacement, and believe me it's not an easy task :P

In essence you need to filter out the tags you require to start with and replace them with tokens (e.g. %BOLD%). It is a string to represent where you want bold tags. You then escape (htmlentities) your output, and then replace your tokens with their real string counterparts.

 

At least this is the way I do it... others may have better suggestions.

Link to comment
https://forums.phpfreaks.com/topic/123228-escaping-outputs/#findComment-636402
Share on other sites

but the $input is text from a richtextarea, which i think will be too much to token replace..

 

before i insert into database, i had mysql_real_escaped_string($input). for some reason because i need to echo out the exact $input to a flash app, can i just echo out $input exactly as it is, without using htmlentities or other escaping functions?

Link to comment
https://forums.phpfreaks.com/topic/123228-escaping-outputs/#findComment-636412
Share on other sites

They're only security holes if you allow untrusted people to enter data that will later be poutputted. This is common in forums and comment systems.

 

Your best bet is to get a WYSIWYG/Rich Text that is already based on 'BBCode', and simply use a PHP BBCode parser. Plenty on google.

Link to comment
https://forums.phpfreaks.com/topic/123228-escaping-outputs/#findComment-636573
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.