Author: jdonnerstag
Date: Fri Aug 31 23:16:31 2007
New Revision: 571708

URL: http://svn.apache.org/viewvc?rev=571708&view=rev
Log:
wicket-894: setStripComments corrupts other HTML tags

fixed (and updated test cases to cover this case)

Modified:
    
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MarkupParser.java
    
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/panel/Fragment.java
    
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTest.java
    
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_1.html
    
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_ExpectedResult_1.html
    
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_ExpectedResult_7.html

Modified: 
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MarkupParser.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MarkupParser.java?rev=571708&r1=571707&r2=571708&view=diff
==============================================================================
--- 
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MarkupParser.java
 (original)
+++ 
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MarkupParser.java
 Fri Aug 31 23:16:31 2007
@@ -44,12 +44,12 @@
 import org.apache.wicket.util.string.AppendingStringBuffer;
 
 /**
- * This is a Wicket MarkupParser specifically for (X)HTML. It makes use of a
- * streaming XML parser to read the markup and IMarkupFilters to remove
- * comments, identify Wicket relevant tags, apply html specific treatments 
etc..
+ * This is a Wicket MarkupParser specifically for (X)HTML. It makes use of a 
streaming XML parser to
+ * read the markup and IMarkupFilters to remove comments, identify Wicket 
relevant tags, apply html
+ * specific treatments etc..
  * <p>
- * The result will be an Markup object, which is basically a list, containing
- * Wicket relevant tags and RawMarkup.
+ * The result will be an Markup object, which is basically a list, containing 
Wicket relevant tags
+ * and RawMarkup.
  * 
  * @see IMarkupFilter
  * @see IMarkupParserFactory
@@ -122,8 +122,8 @@
        }
 
        /**
-        * In case you want to analyze markup which BY DEFAULT does not use 
"wicket"
-        * to find relevant tags.
+        * In case you want to analyze markup which BY DEFAULT does not use 
"wicket" to find relevant
+        * tags.
         * 
         * @param namespace
         */
@@ -133,8 +133,8 @@
        }
 
        /**
-        * Applications which subclass initFilterChain() might also wish to 
access
-        * the markup resource stream.
+        * Applications which subclass initFilterChain() might also wish to 
access the markup resource
+        * stream.
         * 
         * @return The markup resource stream
         */
@@ -144,8 +144,7 @@
        }
 
        /**
-        * Create a new markup filter chain and initialize with all default 
filters
-        * required.
+        * Create a new markup filter chain and initialize with all default 
filters required.
         */
        private final void initializeMarkupFilters()
        {
@@ -185,8 +184,7 @@
        }
 
        /**
-        * By default don't do anything. Subclasses may append additional markup
-        * filters if required.
+        * By default don't do anything. Subclasses may append additional 
markup filters if required.
         * 
         * @see #appendMarkupFilter(IMarkupFilter)
         * @deprecated since 1.3
@@ -208,16 +206,14 @@
        }
 
        /**
-        * Append a new filter to the list of already pre-configured markup 
filters.
-        * Add the new filter before the "beforeFilter" which is identified by 
its
-        * class.
+        * Append a new filter to the list of already pre-configured markup 
filters. Add the new filter
+        * before the "beforeFilter" which is identified by its class.
         * 
         * @param filter
         *            The filter to be appended
         * @param beforeFilter
-        *            The filter will be added before the beforeFilter. If
-        *            beforeFilter == null or beforeFilter not found than 
append to
-        *            the end
+        *            The filter will be added before the beforeFilter. If 
beforeFilter == null or
+        *            beforeFilter not found than append to the end
         */
        public final void appendMarkupFilter(final IMarkupFilter filter, final 
Class beforeFilter)
        {
@@ -458,9 +454,8 @@
        }
 
        /**
-        * Remove all comment sections (&lt;!-- .. --&gt;) from the raw markup. 
For
-        * reasons I don't understand, the following regex
-        * <code>"<!--(.|\n|\r)*?-->"<code>
+        * Remove all comment sections (&lt;!-- .. --&gt;) from the raw markup. 
For reasons I don't
+        * understand, the following regex <code>"<!--(.|\n|\r)*?-->"<code>
         * causes a stack overflow in some circumstances (jdk 1.5) 
         * 
         * @param rawMarkup
@@ -469,20 +464,20 @@
        private String removeComment(String rawMarkup)
        {
                int pos1 = rawMarkup.indexOf("<!--");
-               while (pos1 >= 0)
+               while (pos1 != -1)
                {
                        final int pos2 = rawMarkup.indexOf("-->", pos1 + 4);
 
                        final AppendingStringBuffer buf = new 
AppendingStringBuffer(rawMarkup.length());
-                       if ((pos2 >= 0) && (pos1 > 0))
+                       if (pos2 != -1)
                        {
                                final String comment = rawMarkup.substring(pos1 
+ 4, pos2);
                                if 
(CONDITIONAL_COMMENT.matcher(comment).matches() == false)
                                {
                                        buf.append(rawMarkup.substring(0, 
pos1));
-                                       if (rawMarkup.length() >= pos2 + 4)
+                                       if (rawMarkup.length() >= pos2 + 3)
                                        {
-                                               
buf.append(rawMarkup.substring(pos2 + 4));
+                                               
buf.append(rawMarkup.substring(pos2 + 3));
                                        }
                                        rawMarkup = buf.toString();
                                }

Modified: 
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/panel/Fragment.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/panel/Fragment.java?rev=571708&r1=571707&r2=571708&view=diff
==============================================================================
--- 
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/panel/Fragment.java
 (original)
+++ 
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/panel/Fragment.java
 Fri Aug 31 23:16:31 2007
@@ -328,13 +328,13 @@
                }
 
                // if self doesnt have markup stream try the parent's
-               if (stream == null && getParent() != null)
+               if ((stream == null) && (getParent() != null))
                {
                        stream = getParent().getAssociatedMarkupStream(false);
                }
 
                // if we cant find any markup stream
-               if (stream == null && throwException)
+               if ((stream == null) && throwException)
                {
                        // fail, but fail with an error message that will point 
to this
                        // component

Modified: 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTest.java?rev=571708&r1=571707&r2=571708&view=diff
==============================================================================
--- 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTest.java
 (original)
+++ 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTest.java
 Fri Aug 31 23:16:31 2007
@@ -25,7 +25,6 @@
 import org.apache.wicket.protocol.http.MockHttpServletRequest;
 import org.apache.wicket.settings.IMarkupSettings;
 
-
 /**
  * Test the component: PageView
  * 
@@ -74,6 +73,7 @@
                executeTest(BoxBorderTestPage_3.class, 
"BoxBorderTestPage_ExpectedResult_3.html");
 
                Border border = 
(Border)tester.getLastRenderedPage().get("border");
+               assertNotNull(border);
                Form form = 
(Form)tester.getLastRenderedPage().get("border:myForm");
 
                TextField input = 
(TextField)tester.getLastRenderedPage().get("border:name");
@@ -92,8 +92,8 @@
        }
 
        /**
-        * Test to ensure MarkupException is thrown when Markup and Object 
hierarchy
-        * does not match with a Border involved.
+        * Test to ensure MarkupException is thrown when Markup and Object 
hierarchy does not match with
+        * a Border involved.
         * 
         * @throws Exception
         */

Modified: 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_1.html
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_1.html?rev=571708&r1=571707&r2=571708&view=diff
==============================================================================
--- 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_1.html
 (original)
+++ 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_1.html
 Fri Aug 31 23:16:31 2007
@@ -14,7 +14,7 @@
 -->
 <html>
 <body>
-<span wicket:id="border1">middle-1</span>
+<span wicket:id="border1">middle-1</span><!-- test -->
 <span wicket:id="border2">middle-2</span>
 </body>
 </html>

Modified: 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_ExpectedResult_1.html
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_ExpectedResult_1.html?rev=571708&r1=571707&r2=571708&view=diff
==============================================================================
--- 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_ExpectedResult_1.html
 (original)
+++ 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_ExpectedResult_1.html
 Fri Aug 31 23:16:31 2007
@@ -17,7 +17,7 @@
 <span wicket:id="border1"><wicket:border>
 <!-- with open-close tag -->
 davor <wicket:body>middle-1</wicket:body> danach
-</wicket:border></span>
+</wicket:border></span><!-- test -->
 <span wicket:id="border2"><wicket:border>
 <!-- with separate open and close tag. Body is treated as pre-view region and
      will be removed from output 

Modified: 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_ExpectedResult_7.html
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_ExpectedResult_7.html?rev=571708&r1=571707&r2=571708&view=diff
==============================================================================
--- 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_ExpectedResult_7.html
 (original)
+++ 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_ExpectedResult_7.html
 Fri Aug 31 23:16:31 2007
@@ -1,15 +1,4 @@
-<!--
-====================================================================
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-http://www.apache.org/licenses/LICENSE-2.0
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
--->
+
 <html>
 <body>
 <span>


Reply via email to