FCKeditor leaves many tags open - how to remove them

So, I am using FCKeditor and the problem I am having is that when a user writes a document, sometimes the information is copied from Word, sometimes it is written directly in the editor, and other times it can be done both ways. What this leaves me in the DB is a lot of tags that are open and never close. This changes my layout drastically and I am trying to find a solution.

I modified the config file to insert it as plain text, which I assumed would stop Word's formatting transfer and it still does.

So now I'm trying to find a way to find the opening tags and remove them before the information is sent to the DB. Or is there some FCKeditor feature / config that I am missing to help me?

Any suggestions on how I should proceed?

Thanks
Levy

+2


source to share


2 answers


As well as a security precaution that will address both security-related issues (like <script>

user-inserted tags , for example, which you probably don't want) and presentation-related issues (like non-closed tags), you can use on your server, a tool like HTMLPurifier based on what you get from the browser.

Of course, this does not solve the first problem, the fact that users can enter whatever they want into FCKEditor; but this will ensure that your HTML is valid and safe.

Actually, even if FCKEditor didn't get you invalid HTML, you can still use HTMLPurifier, just for security.



The idea is that you provide a list:

  • valid tags
  • allowed attributes for these tags

And in turn, HTMLPurifier gives you clean and valid HTML.

+2


source


Edit: It looks like you are running a bug in the editor. You can try another one, and / or use a server side script that goes through and separates the unmatched div tags.

Html allows you to keep all tags open. If they leave tags open that need to be closed, you can whitelist or blacklist them and remove those servers. Otherwise you are pretty much stuck with the understanding that HTML is not XML, FCKeditor will generate HTML and HTML will not be validated as XML. If it discards the printed output, try wrapping the FCKeditor output in a div.



Otherwise, please provide specific examples of input and output that messed up your page layout.

0


source







All Articles