Return-Path: Delivered-To: apmail-struts-dev-archive@www.apache.org Received: (qmail 16400 invoked from network); 3 Sep 2005 15:43:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 3 Sep 2005 15:43:29 -0000 Received: (qmail 71123 invoked by uid 500); 3 Sep 2005 15:43:16 -0000 Delivered-To: apmail-struts-dev-archive@struts.apache.org Received: (qmail 70944 invoked by uid 500); 3 Sep 2005 15:43:15 -0000 Mailing-List: contact dev-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Developers List" Reply-To: "Struts Developers List" Delivered-To: mailing list dev@struts.apache.org Received: (qmail 70880 invoked by uid 500); 3 Sep 2005 15:43:15 -0000 Received: (qmail 70859 invoked by uid 99); 3 Sep 2005 15:43:15 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Sep 2005 08:43:15 -0700 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Sat, 03 Sep 2005 08:43:29 -0700 Received: (qmail 16340 invoked by uid 65534); 3 Sep 2005 15:43:13 -0000 Message-ID: <20050903154313.16339.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r267474 - in /struts/shale/trunk/clay-plugin/src: java/org/apache/shale/clay/parser/Parser.java test/org/apache/shale/clay/parser/ParserTestCase.java Date: Sat, 03 Sep 2005 15:43:13 -0000 To: commits@struts.apache.org From: gvanmatre@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: gvanmatre Date: Sat Sep 3 08:42:54 2005 New Revision: 267474 URL: http://svn.apache.org/viewcvs?rev=267474&view=rev Log: Bug#: 35839 [shale] Clay processes components inside HTML comments Modified: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/Parser.java struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/parser/ParserTestCase.java Modified: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/Parser.java URL: http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/Parser.java?rev=267474&r1=267473&r2=267474&view=diff ============================================================================== --- struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/Parser.java (original) +++ struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/Parser.java Sat Sep 3 08:42:54 2005 @@ -457,8 +457,7 @@ new Rule('-', true, 3, true), new Rule('>', false, -1, true), new Rule('-', false, -2, true), - new Rule('-', false, -3, true), - new Rule(' ', false, -4, true)}; + new Rule('-', false, -3, true)}; /** *

Declare an array of {@link Rule}s that validate a begin comment {@link Token}.

@@ -473,8 +472,7 @@ */ public static Rule[] END_COMMENT_TAG_RULES = {new Rule('>', false, -1, true), new Rule('-', false, -2, true), - new Rule('-', false, -3, true), - new Rule(' ', false, -4, true)}; + new Rule('-', false, -3, true)}; /** *

Declare an array of {@link Rule}s that validate document type {@link Token}.

@@ -517,6 +515,9 @@ nextShape: for (int i = 0; i < NODE_SHAPES.length; i++) { + int maxBeginOffset = 0; + int minEndOffset = Integer.MAX_VALUE; + Shape shape = NODE_SHAPES[i]; Rule[] rules = shape.getRules(); @@ -525,6 +526,12 @@ // use the begin or end token offset int n = (rules[j].isBegin ? token.getBeginOffset() : token.getEndOffset()) + rules[j].getOffset(); + if (rules[j].isBegin) + maxBeginOffset = Math.max(n, maxBeginOffset); + else + minEndOffset = Math.min(n, minEndOffset); + + // if out of document range, look for the next shape if (n > token.getDocument().length() || n < 0) continue nextShape; @@ -539,6 +546,10 @@ if (!match) continue nextShape; } + + //make sure the compared token delimiters don't overlap + if (minEndOffset <= maxBeginOffset) + continue nextShape; node.setStart(shape.isStart()); node.setEnd(shape.isEnd()); Modified: struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/parser/ParserTestCase.java URL: http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/parser/ParserTestCase.java?rev=267474&r1=267473&r2=267474&view=diff ============================================================================== --- struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/parser/ParserTestCase.java (original) +++ struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/parser/ParserTestCase.java Sat Sep 3 08:42:54 2005 @@ -55,13 +55,12 @@ doc1.append("

").append( "").append( - "

").append("").append( - "" + - " -->"); + "-->").append( + "

").append("").append( + ""); List nodes1 = p.parse(doc1); - assertTrue("Has 4 root nodes", nodes1.size() == 4); + assertTrue("Has 3 root nodes", nodes1.size() == 3); Node node = (Node) nodes1.get(0); assertTrue("first paragraph has 2 node", node.getChildren().size() == 2); @@ -74,10 +73,6 @@ assertTrue("third comment has 7 child nodes", node.getChildren() .size() == 7); - node = (Node) nodes1.get(3); - assertTrue("forth comment has 1 child node", node.getChildren() - .size() == 1); - // truncate the buffer doc1.setLength(0); @@ -96,6 +91,37 @@ node = (Node) node.getChildren().get(0); assertTrue("comment has 5 child nodes", node.getChildren().size() == 5); + // truncate the buffer + doc1.setLength(0); + doc1.append(""); + + nodes1 = p.parse(doc1); + assertTrue("one root node", nodes1.size() == 1); + + node = (Node) nodes1.get(0); + assertTrue("node is a valid comment", node.isComment()); + + // truncate the buffer + doc1.setLength(0); + doc1.append("-->"); + + nodes1 = p.parse(doc1); + assertTrue("one root node", nodes1.size() == 1); + + node = (Node) nodes1.get(0); + assertTrue("node is a valid comment", node.isComment()); + + // truncate the buffer + doc1.setLength(0); + doc1.append(""); + + nodes1 = p.parse(doc1); + assertTrue("one root node", nodes1.size() == 1); + + node = (Node) nodes1.get(0); + assertTrue("node is a valid comment", node.isComment()); + + } /** --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org For additional commands, e-mail: dev-help@struts.apache.org