schwim;10886513 wrote:Currently, I'm using some snippets from the comments, but there's a couple things that concern me. There's no validation to the snippets.
Fortunately, there's a specific format to html. Has to be or browsers cannot render it. I mean, a script tag ALWAYS starts with a "<script" and ends with a "</script>." There's just no way around it. If I see a code suggestion, the best way to trust it is to see if it works by testing it. You can get a lot of source code from the internet to test it against, for example.
schwim;10886513 wrote:
Also, I thought there would be a function that was widely used due to it's security and features. That very well may not be the case, but it is always worth a shot 🙂
There is, strip_tags(). Basically, you just don't want a malicious user to post anything that can facilitate cross-site browser attacks (like javascript for example.) At it's core, strip_tags() is very useful for cleaning out html when it's not allowed (usually because of this very issue.) However, you didn't want to get rid of all html. Fortunately, you can pass the tags you'd like to leave. For example, you could tell it to leave paragraphs, breaks, or other layout tags considered safe.