Since WordPress 2.0, WP has included a visual editor (TinyMCE). Users of WP don't need to know HTML.
If I write a new post with the following content, it will break the page where the content will appear.
Or anything that's a closing tag.
Not in the visual editor of the current version of WordPress (2.5.1):
In WP 2.5, the visual editor automatically converts greater-than, less-than, and other symbols to their respect entity values (
In WP 2.5, if one switches back and forth from the code editor to the visual editor, nesting errors are automatically corrected.*
If a (1) user enters something in the "code view;" (2) the user does not switch back to the visual editor before saving the post; and (3) the "correct invalidly nested XHTML" option (see below) is not checked, then the above is possible.*
And, yes, if a user enters code in the visual editor of the 2.0 legacy branch, that is not automatically corrected or converted to entities.*
Is there a way to filter or validate the code before it gets publish.
Don't use the code view. Or, if you are using the code view, then in the Settings > Writing page, mark the checkbox labeled " WordPress should correct invalidly nested XHTML automatically". This is unchecked by default, as most users only use the visual editor and (as I understand it,) for plugin compatibility issues. See the Codex page for the Writing options subpanel). And, if one is obsessive about validation, they can always manually run their pages through the W3 validator.
*I checked all of this on new, clean installs of WP 2.0.11 and WP 2.5.1.