In my CakePHP blog, I want to enable users to make similar HTML additions as you can insert here on StackOverflow, i.e. line breaks, links, bold, lists etc. But I am a little unsure how I shall tackle this issue in terms of what is most practical whilst maintaining protection against malicious code in the posts users submit.
- Practically is it the most convenient to save the post in a TEXT database field and allow some HTML in that?
- If I allow some HTML code in the post, how do I ensure that I only allow non-malicious basic HTML code whilst cleaning out the rest?
- Should I be using the CakePHP Sanitize class for that somehow?
- Will the FormHelper clean out all HTML users input?
- I assume I'll have to use JavaScript to help users generate the right code?