ScaryBinary
November 15th, 2004, 10:07 PM
Howdy,
I know that a string can be made HTML safe (using htmlentities(), for instance). The problem I have is that I want to convert text that contains a mix of normal text, which should be made safe, and actual HTML which should be preserved.
For example, I might have the following string stored in a database:
My latest photo is called "What's That Smell?". Please <a href="vote.php">tell me what you think</a>.
When I pull it from the database and dump it to the browser, I still want the link to work, so I can't run it through htmlentities() or my HTML will be rendered as normal text. I want to end up with something like (sorry, had to use colons instead of semi-colons so the BBS didn't render the HTML)...
My latest photo is called ":What':s That Smell?":. Please <a href="vote.php">tell me what you think</a>
...which will fix the "normal" text but still allow the browser to interpret the HTML.
Does anyone have a function that does this already? I'm sure I could write one using regular expressions and such, but I didn't want to reinvent the wheel if someone has done this before.
Thanks!
I know that a string can be made HTML safe (using htmlentities(), for instance). The problem I have is that I want to convert text that contains a mix of normal text, which should be made safe, and actual HTML which should be preserved.
For example, I might have the following string stored in a database:
My latest photo is called "What's That Smell?". Please <a href="vote.php">tell me what you think</a>.
When I pull it from the database and dump it to the browser, I still want the link to work, so I can't run it through htmlentities() or my HTML will be rendered as normal text. I want to end up with something like (sorry, had to use colons instead of semi-colons so the BBS didn't render the HTML)...
My latest photo is called ":What':s That Smell?":. Please <a href="vote.php">tell me what you think</a>
...which will fix the "normal" text but still allow the browser to interpret the HTML.
Does anyone have a function that does this already? I'm sure I could write one using regular expressions and such, but I didn't want to reinvent the wheel if someone has done this before.
Thanks!