Forum Moderators: not2easy
I know the easiest way would be to just allow plain text to be submitted and sleep in peace, but I'd like the idea to gave them the posibility as have some formatting like using <b>'s, <i>'s, and <a href>'s.
I'm doing this myself, I mean, I don't have, use or have ever used a Content Management System.
What do you usually do in this situation?
remove-unwanted-markup {[b]<a href="ffff">test</a> <p> <table><b>text</b></table>[/b]}[b]<a href="ffff">test</a> <b>text</b>[/b]
The function looks like this:
rebol []
remove-unwanted-markup: func [in-text [string!]
/local
out-text
allowed-markup
][
allowed-markup: [<a> </a> <b> </b> <u> </u> <strong> </strong>] ; etc
out-text: copy ""
foreach str load/markup in-text [
either tag? str [
if find allowed-markup to-tag first parse str none [
append out-text str] ; allowed tag
][append out-text str ; string
]
]
return trim/lines out-text
]
That's written in REBOL. You may need to find the equivalent in your chosen CGI scripting language.