Wicket
  1. Wicket
  2. WICKET-4494

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

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.5
    • Fix Version/s: 1.5.6, 6.0.0-beta2
    • Component/s: wicket
    • Labels:
      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

      1. HtmlHandlerTest.tgz
        20 kB
        Michal Jirkovsky

        Activity

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        23h 56m 1 Martin Grigorov 13/Apr/12 12:48
        Martin Grigorov made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Martin Grigorov [ mgrigorov ]
        Fix Version/s 1.5.6 [ 12319053 ]
        Fix Version/s 6.0.0-RC1 [ 12320343 ]
        Resolution Fixed [ 1 ]
        Hide
        Martin Grigorov added a comment -

        Thanks!

        Show
        Martin Grigorov added a comment - Thanks!
        Michal Jirkovsky made changes -
        Description Hi,

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

        <img alt="" src="img/supplier/supplier1.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="" src="img/supplier/supplier1.png">' in org.apache.wicket.util.resource.StringBufferResourceStream@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
        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
        Michal Jirkovsky made changes -
        Field Original Value New Value
        Attachment HtmlHandlerTest.tgz [ 12522404 ]
        Hide
        Michal Jirkovsky added a comment -

        Quickstart app that demonstrates the problem.

        Show
        Michal Jirkovsky added a comment - Quickstart app that demonstrates the problem.
        Michal Jirkovsky created issue -

          People

          • Assignee:
            Martin Grigorov
            Reporter:
            Michal Jirkovsky
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development