Updated Branches:
refs/heads/5.3 dbd207eaf -> d361d5c44
TAP5-1976: XML Parser adds attributes with default values and produces invalid
HTML5 markup
Conflicts:
tapestry-core/src/test/java/org/apache/tapestry5/internal/services/TemplateParserImplTest.java
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/d361d5c4
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/d361d5c4
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/d361d5c4
Branch: refs/heads/5.3
Commit: d361d5c4457dc3a109256763a1ce9b9d8367ce4e
Parents: dbd207e
Author: Howard M. Lewis Ship <[email protected]>
Authored: Fri Aug 17 16:11:22 2012 -0700
Committer: Howard M. Lewis Ship <[email protected]>
Committed: Fri Aug 17 16:20:48 2012 -0700
----------------------------------------------------------------------
.../tapestry5/corelib/components/Alerts.java | 8 +---
.../internal/services/XMLTokenStream.java | 13 +++++-
.../internal/services/TemplateParserImplTest.java | 32 ++++++++++++++-
.../services/default_attributes_not_included.tml | 1 +
4 files changed, 46 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d361d5c4/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Alerts.java
----------------------------------------------------------------------
diff --git
a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Alerts.java
b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Alerts.java
index c82e02d..fe00840 100644
---
a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Alerts.java
+++
b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Alerts.java
@@ -14,17 +14,13 @@
package org.apache.tapestry5.corelib.components;
+import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.ClientElement;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.alerts.Alert;
import org.apache.tapestry5.alerts.AlertStorage;
-import org.apache.tapestry5.annotations.Environmental;
-import org.apache.tapestry5.annotations.Parameter;
-import org.apache.tapestry5.annotations.RequestParameter;
-import org.apache.tapestry5.annotations.SessionState;
-import org.apache.tapestry5.annotations.SupportsInformalParameters;
-import org.apache.tapestry5.BindingConstants;
+import org.apache.tapestry5.annotations.*;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.javascript.InitializationPriority;
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d361d5c4/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/XMLTokenStream.java
----------------------------------------------------------------------
diff --git
a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/XMLTokenStream.java
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/XMLTokenStream.java
index c0be8a8..df2f6b4 100644
---
a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/XMLTokenStream.java
+++
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/XMLTokenStream.java
@@ -1,4 +1,4 @@
-// Copyright 2009, 2011 The Apache Software Foundation
+// Copyright 2009, 2011, 2012 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@ import
org.apache.tapestry5.ioc.internal.util.CollectionFactory;
import org.apache.tapestry5.ioc.internal.util.InternalUtils;
import org.apache.tapestry5.ioc.internal.util.LocationImpl;
import org.xml.sax.*;
+import org.xml.sax.ext.Attributes2;
import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.helpers.XMLReaderFactory;
@@ -198,6 +199,8 @@ public class XMLTokenStream
// The XML parser tends to reuse the same Attributes object, so
// capture the data out of it.
+ Attributes2 a2 = (attributes instanceof Attributes2) ?
(Attributes2) attributes : null;
+
if (attributes.getLength() == 0)
{
token.attributes = Collections.emptyList();
@@ -207,6 +210,14 @@ public class XMLTokenStream
for (int i = 0; i < attributes.getLength(); i++)
{
+ // Filter out attributes that are not present in the XML
input stream, but were
+ // instead provided by DTD defaulting.
+
+ if (a2 != null && !a2.isSpecified(i))
+ {
+ continue;
+ }
+
String prefixedName = attributes.getQName(i);
int lastColon = prefixedName.lastIndexOf(':');
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d361d5c4/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/TemplateParserImplTest.java
----------------------------------------------------------------------
diff --git
a/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/TemplateParserImplTest.java
b/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/TemplateParserImplTest.java
index 46f0d58..862c599 100644
---
a/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/TemplateParserImplTest.java
+++
b/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/TemplateParserImplTest.java
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008, 2009, 2010, 2011 The Apache Software Foundation
+// Copyright 2006-2012 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -1001,6 +1001,36 @@ public class TemplateParserImplTest extends
InternalBaseTestCase
TextToken token1 = get(tokens, 1);
assertEquals(token1.text, "\n[\u00A0]\n");
+ }
+
+ /**
+ * See <a
href="https://issues.apache.org/jira/browse/TAP5-1976">TAP5-1976</a>
+ *
+ * @since 5.3.5
+ */
+ @Test
+ public void default_attributes_not_included()
+ {
+ List<TemplateToken> tokens =
tokens("default_attributes_not_included.tml");
+
+ assertEquals(tokens.size(), 2);
+
+ // TAP5-1976 meant that a default attribute ("Attribute[shape=rect]")
would be included.
+
+ assertEquals(toString(tokens), "Start[a] End");
+ }
+
+ private String toString(List<TemplateToken> tokens)
+ {
+ StringBuilder builder = new StringBuilder();
+ String sep = "";
+
+ for (TemplateToken token : tokens)
+ {
+ builder.append(sep).append(token.toString());
+ sep = " ";
+ }
+ return builder.toString();
}
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d361d5c4/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/default_attributes_not_included.tml
----------------------------------------------------------------------
diff --git
a/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/default_attributes_not_included.tml
b/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/default_attributes_not_included.tml
new file mode 100644
index 0000000..bb9b580
--- /dev/null
+++
b/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/default_attributes_not_included.tml
@@ -0,0 +1 @@
+<a/>
\ No newline at end of file