PDA

View Full Version : Replacing Characters On Condition


megamanXplosion
09-04-2002, 06:46 PM
I have a message board (invision board) and I've edited the post_parser.php file to let someone use and to enter a javascript statement to execute (not show, execute). However....

The message board automatically inserts <br> in the place of line breaks, using this code....

$txt = preg_replace( "/<br>|<br\s*\/>/", "\n", $txt );

Is there anyway to make that conditional? As in, it'll replace line breaks with <br>, but if it's between and it won't?

mordred
09-04-2002, 07:04 PM
That's not correct - the snippet above replaces <br> or <br /> tags with line breaks, so it works the other way round than you described.

Besides, you are aware of cross-site scripting attacks by letting your users execute javascript through your board?

megamanXplosion
09-04-2002, 07:09 PM
sorry, I meant this line....

$txt = preg_replace( "/\n/", "<br>", $txt );

and is for the security issues, I am aware of them. I am going to be the only person on the message board capable of using javascript. I am wanting to post a bunch of tutorials for people and I need to be able to create examples along with the tutorials.


Thanks.

megamanXplosion
09-04-2002, 07:45 PM
come up with anything?