Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-4494

HtmlHandler wrongly handles tags not requiring closed tags if the markup does not have "top" level tag

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.5.5
    • 1.5.6, 6.0.0-beta2
    • wicket
    • None

    Description

      Hi,

      I have custom component (extends MarkupContainer implements IMarkupCacheKeyProvider, IMarkupResourceStreamProvider) which fetches its HTML markup from database.
      Following HTML markup:

      <img alt="" src="logo.png">
      <br>Some text
      <br>Some more text

      causes following error:

      2012-04-12 10:52:53,012 [http-8080-6] ERROR: Unexpected error occurred
      Unable to find close tag for: '<img alt="logo" src="logo.png">' in org.apache.wicket.util.resource.StringResourceStream@3d7e16fc
      MarkupStream: [unknown]
      at org.apache.wicket.markup.MarkupFragment.<init>(MarkupFragment.java:127)
      at org.apache.wicket.markup.MarkupStream.getMarkupFragment(MarkupStream.java:485)
      at org.apache.wicket.MarkupContainer.autoAdd(MarkupContainer.java:244)
      at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1421)
      at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1596)
      at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1571)
      at org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1525)

      I think the problem is that org.apache.wicket.markup.parser.filter.HtmlHandler does not handle such markup correctly. It does not call ComponentTag.setHasNoCloseTag(true) for the img tag. Such call is missing in postProcess() method. I think that this problem can be fixed by inserting:

      top.setHasNoCloseTag(true);

      after line 80 in HtmlHandler.java file.

      Michal

      Attachments

        1. HtmlHandlerTest.tgz
          20 kB
          Michal Jirkovsky

        Activity

          People

            mgrigorov Martin Tzvetanov Grigorov
            mjirkovsky Michal Jirkovsky
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: