[ 
https://issues.apache.org/jira/browse/WICKET-4136?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Martin Grigorov updated WICKET-4136:
------------------------------------

    Comment: was deleted

(was: Here is a possible fix:

Index: wicket-core/src/main/java/org/apache/wicket/markup/MarkupFragment.java
===================================================================
--- wicket-core/src/main/java/org/apache/wicket/markup/MarkupFragment.java      
(revision 1185526)
+++ wicket-core/src/main/java/org/apache/wicket/markup/MarkupFragment.java      
(working copy)
@@ -96,8 +96,12 @@
                                MarkupElement elem = markup.get(endIndex);
                                if (elem instanceof ComponentTag)
                                {
-                                       endIndex--;
-                                       break;
+                                       ComponentTag endTag = 
(ComponentTag)elem;
+                                       if (endTag.closes(startTag))
+                                       {
+                                               endIndex--;
+                                               break;
+                                       }
                                }
                        }
                }

But this makes Wicket stricter and markup like:
<head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <link rel="shortcut icon" href="assets/img/icons/favicon.ico">
        <title wicket:id="pageTitle">[title]</title>
</head>
is no more valid because <link> has no closing tag (i.e validates against 
XHTML). But this markup is valid HTML and <link> doesn't require closing tag.

I also prefer XML well formed markup in my apps but such a change will break 
quite a lot of applications in production.)
    
> component without close tag fails with "Unable to find close tag for" if it 
> is the last componet on page
> --------------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-4136
>                 URL: https://issues.apache.org/jira/browse/WICKET-4136
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5.1
>            Reporter: Kent Tong
>            Priority: Minor
>   Original Estimate: 10m
>  Remaining Estimate: 10m
>
> A simple page with the following markup will fail:
> <html>
> <img wicket:id="photo">
> </html>
> but this one will work:
> <html>
> <img wicket:id="photo">
> <span wicket:id="label" />
> </html>
> I believe the bug is in the code below:
>       public MarkupFragment(final IMarkupFragment markup, final int 
> startIndex)
>       {
>               if (...) 
>               {
>                  ...
>               }
>               else if (startTag.hasNoCloseTag())
>               {
>                       for (endIndex = startIndex + 1; endIndex < 
> markup.size(); endIndex++)
>                       {
>                               MarkupElement elem = markup.get(endIndex);
>                               if (elem instanceof ComponentTag)  // It looks 
> for another component tag to indicate the end of the body, but fails if it is 
> the last one
>                               {
>                                       endIndex--;
>                                       break;
>                               }
>                       }
>               }
>               else
>               {
>                  ...
>               }
>               if (endIndex >= markup.size())
>               {
>                       throw new MarkupException("Unable to find close tag 
> for: '" + startTag.toString() +
>                               "' in " + 
> getRootMarkup().getMarkupResourceStream().toString());
>               }
>       }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to