Forum Moderators: not2easy

Message Too Old, No Replies

Allowable markup in submited articles.

Which tags do you allow?

         

fischermx

5:42 am on Jul 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm starting an application to receive submmited articlces, events and press releases from peers.

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?

victor

9:46 am on Jul 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I run the user's input through a filter to leave only the markup I permit. eg:


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.