Menu

#128 Regression: <legend> tag is stripped

v 2.10
closed-fixed
nobody
None
5
2014-10-30
2014-09-25
No

This used to be fixed by https://sourceforge.net/p/htmlcleaner/bugs/42/ but it has come back again.

See http://jira.xwiki.org/browse/XWIKI-11118

Input example:

<html><head /><body><fieldset><legend>test</legend><div>content</div></fieldset></body></html>

is cleaned as:

<html><head></head><body><fieldset>test<div>content</div></fieldset></body></html>

Discussion

  • Vincent Massol

    Vincent Massol - 2014-09-25

    Found a test for it in HtmlCleanerTest but this test has no asserts!

        @Test
        public void testOOME_59() throws Exception {
            String in = "<html><body><table><fieldset><legend>";
            CleanerProperties cp = new CleanerProperties();
            HtmlCleaner c = new HtmlCleaner(cp);
            TagNode root = c.clean(in);
        }
    
     
  • Vincent Massol

    Vincent Massol - 2014-09-25

    hmm actually if I modify it like this it passes so the problem is elsewhere...

        @Test
        public void testOOME_59() throws Exception {
            String in = "<html><body><table><fieldset><legend>";
            CleanerProperties cp = new CleanerProperties();
            HtmlCleaner c = new HtmlCleaner(cp);
            TagNode root = c.clean(in);
            assertEquals(1, root.getElementsByName("legend", true).length);
        }
    
     
  • Vincent Massol

    Vincent Massol - 2014-09-25

    ok found the problem, it's apparently an unknown tag:

            cp.setOmitUnknownTags(true);
    

    This makes the test fail. Now checking why it's an unknown tag...

     
  • Vincent Massol

    Vincent Massol - 2014-09-25

    Seems it's just missing from DefaultTagProvider()...

    I see that it was added in rev 110:

    ~~~~~
    + tagInfo = new TagInfo("legend", TagInfo.CONTENT_TEXT, TagInfo.BODY, false, false, false);
    + tagInfo.defineRequiredEnclosingTags("fieldset");
    + tagInfo.defineCloseBeforeTags("legend");
    + this.put("legend", tagInfo);
    ~~~~

     
  • Vincent Massol

    Vincent Massol - 2014-09-25

    So the regression was done by patmoore in:

    r203 | patmoore | 2013-02-26 05:53:49 +0100 (Tue, 26 Feb 2013) | 44 lines

    Where he did this:

    -        tagInfo = new TagInfo("legend", TagInfo.CONTENT_TEXT, TagInfo.BODY, false, false, false);
    -        tagInfo.defineRequiredEnclosingTags("fieldset");
    -        tagInfo.defineCloseBeforeTags("legend");
    -        this.put("legend", tagInfo);
    

    :(

     
  • Vincent Massol

    Vincent Massol - 2014-09-25

    Could someone help out on this since I don't fully understand the parameters to use for registering a new tag?

    I've tried the following but it's not correct as it fails the test:

            tagInfo = new TagInfo("legend", ContentType.all, BelongsTo.BODY, false, false, false, CloseTag.required, Display.block);
            tagInfo.defineRequiredEnclosingTags("fieldset");
            tagInfo.defineCloseBeforeTags("legend");
            this.put("legend", tagInfo);
    
     
  • Vincent Massol

    Vincent Massol - 2014-09-25

    The following works but it's probably not correct:

            tagInfo = new TagInfo("legend", ContentType.all, BelongsTo.BODY, false, false, false, CloseTag.required, Display.block);
            this.put("legend", tagInfo);
    
     
  • Scott Wilson

    Scott Wilson - 2014-09-26

    Hmm, looks like it was removed as it causes an out-of-memory error when defined correctly, which is like this:

            tagInfo = new TagInfo("legend", ContentType.all, BelongsTo.BODY, false, false, false, CloseTag.required, Display.block);
            tagInfo.defineRequiredEnclosingTags("fieldset");
            tagInfo.defineAllowedChildrenTags(PHRASING_TAGS);
            this.put("legend", tagInfo);
    

    (Hence the unit test being called "OOME")

    If I remove the requirement to be enclosed by the fieldset tag, everything works fine.

    For now I'll add back in the definition, but with the fieldset requirement commented out with a note about the OOME, and raise another bug for that.

     
  • Scott Wilson

    Scott Wilson - 2014-09-26
    • status: open --> closed-fixed
     
  • Scott Wilson

    Scott Wilson - 2014-09-26

    Tests now pass with "omitUnknownTags" set - I've created a new bug 129 to track the fieldset OOME issue, so I'm closing this one.

     
  • Scott Wilson

    Scott Wilson - 2014-09-26
    • Group: v 2.9 --> v 2.10
     
  • Vincent Massol

    Vincent Massol - 2014-10-14

    Hi Scott,

    The XWiki project is waiting for HC 2.10 to be released in order to get this regression fixed. Any ETA for that? Thanks!

     
  • Scott Wilson

    Scott Wilson - 2014-10-14

    I'd pencilled in 31st October for releasing 2.10 (Halloween!)

     
  • Vincent Massol

    Vincent Massol - 2014-10-14

    ok, waiting for that date eagerly then :) Thanks!

     
  • Vincent Massol

    Vincent Massol - 2014-10-30

    Still planned for tomorrow? :)

    Thanks!

     
  • Scott Wilson

    Scott Wilson - 2014-10-30

    Yup, all ready to go :)

     
  • Vincent Massol

    Vincent Massol - 2014-10-30

    great!

     

Log in to post a comment.