In Drupal one of the text filters that is enabled by default is the filter Correct faulty and chopped off HTML. As I understand it must fix HTML bugs.

Can anybody please give some example(s) of situations, where it can help?

I am confused, because if I do not close some tag (for example DIV), and save the result, then I get the same result in both cases (= it doesn't matter if that filter is turned on or off).


In Drupal, there is rule that a text filter should never change anything that the user saves. The "Correct faulty and chopped off HTML" follows this rule. That is why you don't see any changes in the body field when you edit.

However, the filter will fix your HTML when the text in the body field is rendered (i.e. displayed to the user).

For instance, if you use the Drupal 6 or 7 "Filtered HTML" text type (which makes use this filter) and put the following faulty and chopped off HTML in the body (this is all you put in the body of a node):


and examine the rendered HTML in your browser (for instance using Ctrl-U or Firebug in Firefox), you'll see that it is corrected to:


Screen shots

Text in editor:

enter image description here

Rendered text, as displayed by Firebug:

enter image description here

  • I know about this rule. May be you do not understand me. I see the result in firebug . And any different when the filter is turned on and when off - I do not see. Even if I use your exapmle. You can try it too, and see. May be in drupal render function this filter is present to? Otherwise how to explain it? May 23 '15 at 6:21
  • "You can try it too, and see." I did. I've now added screenshots from the editor and from Firebug to the answer to illustrate what I see. What I observe on my test site (a clean install of Drupal 7) is clearly different from what you see. (I've no idea why you're unable to see it, but I am pretty confident that this text filter works the way I've described it.) May 23 '15 at 7:23
  • Yes, but if you go to the admin/config/content/formats/filtered_html and disable filter "Correct faulty and chopped off HTML" - You will see the same result. Nothing will change. The question is, why did this filter need? and why if it disabled we get the correct html in output? I don not understand. Thank you for you time and answer. May 23 '15 at 9:46
  • Sorry, please. You were write. I do not understand why I see the same result in both cases. May be it was the browher cache. I check many time, before I write here. When I clear cache site and browser and test again, I see the result of filter. I asked this question here, because I really could not understand how this could be. But now everything is clear. Thank you. May 23 '15 at 9:59
  • @bigferumdron Depending on what browser you use, and how you're inspecting the source, you might be getting fooled. Chrome, for example, will correct your faulty HTML in the inspector for you. So <ul><li>xyzzy will appear as <ul><li>xyzzy</li></ul>, unless you actually view the raw source of the page. It's worth remembering, that's caught me out a few times before. Always right click, view source to get the full picture
    – Clive
    May 23 '15 at 10:50

Refer to these 3 issues that contain a reference to that "Correct faulty and chopped off HTML" filter.

In these cases it has to do with the usage of some 3rd party library that generates something (like SVGs), which occasionally may produce xHTML that is not 100 % correct. Refer to this issue comment for an illustration of how I ever got in XML parsing errors, because of such HTML filter issues ...

So if you're a module (co-)maintainer using a 3rd party library that has such issues, then this faulty-work around is about the only thing you can do to address that somehow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.