Forum Moderators: open

Message Too Old, No Replies

Remove <a href

         

miedmark

2:02 am on Mar 31, 2006 (gmt 0)

10+ Year Member



When someone makes a post and uses <a href in their text, text gets converted into live link. How can I remove this, or stop users from doing this. It is asp, using .mdb file, and field is memo. Thanks.

txbakers

4:18 am on Mar 31, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When they make the submit, before you write it to the database, do a String(field).replace("<a href","") which will remove the code.

You might want to make this more elegant though.

brickwall

5:25 am on Mar 31, 2006 (gmt 0)

10+ Year Member



it is always a good idea to do some processing on text submitted on your form fields before committing them to the db. prevents a lot of problems later on, especially those dreaded sql injections.

carguy84

6:45 am on Mar 31, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Use a regular expression. A straight up replace won't work, because the < a href could look like:
<a title="Bon Jovi" href="example.com" >

mattglet

11:59 am on Mar 31, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Another feasible option other than the regex would be to replace all "<" and ">" with "&lt;" and "&gt;" before inserting into the database.

Of course, when it's displayed on the page, it will output the code like this:

< a href = "example.com" >Something here< /a >