You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2012/02/22 10:17:42 UTC
git commit: WICKET-4425 Wicket 1.5 rewrites template content where it
should not
Updated Branches:
refs/heads/wicket-1.5.x 2a4d6c151 -> fda2e7962
WICKET-4425 Wicket 1.5 rewrites template content where it should not
Do not wrap in CDATA <script> elements which type is not plain javascript.
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/fda2e796
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/fda2e796
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/fda2e796
Branch: refs/heads/wicket-1.5.x
Commit: fda2e7962446aba5059eb88e2aad22090c07be73
Parents: 2a4d6c1
Author: martin-g <mg...@apache.org>
Authored: Wed Feb 22 10:16:08 2012 +0100
Committer: martin-g <mg...@apache.org>
Committed: Wed Feb 22 10:16:08 2012 +0100
----------------------------------------------------------------------
.../parser/filter/StyleAndScriptIdentifier.java | 32 +++++++++++---
1 files changed, 25 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/fda2e796/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/StyleAndScriptIdentifier.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/StyleAndScriptIdentifier.java b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/StyleAndScriptIdentifier.java
index bcc8634..957de64 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/StyleAndScriptIdentifier.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/StyleAndScriptIdentifier.java
@@ -28,21 +28,23 @@ import org.apache.wicket.util.string.JavaScriptUtils;
/**
+ * An IMarkupFilter that wraps the body of all <style> elements and <script>
+ * elements which are plain JavaScript in CDATA blocks. This allows the user application
+ * to use unescaped XML characters without caring that those may break Wicket's XML Ajax
+ * response.
*
* @author Juergen Donnerstag
*/
public final class StyleAndScriptIdentifier extends AbstractMarkupFilter
{
- private final Markup markup;
-
/**
- * Construct.
+ * Constructor.
*
* @param markup
+ * Unused. Will be removed in next major version.
*/
- public StyleAndScriptIdentifier(final Markup markup)
+ public StyleAndScriptIdentifier(@SuppressWarnings("unused")final Markup markup)
{
- this.markup = markup;
}
@Override
@@ -79,7 +81,8 @@ public final class StyleAndScriptIdentifier extends AbstractMarkupFilter
if (elem instanceof ComponentTag)
{
ComponentTag open = (ComponentTag)elem;
- if (open.getUserData("STYLE_OR_SCRIPT") != null)
+
+ if (shouldProcess(open))
{
if (open.isOpen() && ((i + 2) < markup.size()))
{
@@ -106,4 +109,19 @@ public final class StyleAndScriptIdentifier extends AbstractMarkupFilter
}
}
}
-}
+
+ private boolean shouldProcess(ComponentTag openTag)
+ {
+ // do not wrap in CDATA any <script> which has special MIME type. WICKET-4425
+ String typeAttribute = openTag.getAttribute("type");
+ boolean shouldProcess =
+ // style elements should be processed
+ "style".equals(openTag.getName()) ||
+
+ // script elements should be processed only if they have no type (HTML5 recommendation)
+ // or the type is "text/javascript"
+ (typeAttribute == null || "text/javascript".equalsIgnoreCase(typeAttribute));
+
+ return shouldProcess && openTag.getUserData("STYLE_OR_SCRIPT") != null;
+ }
+}
\ No newline at end of file