You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by sv...@apache.org on 2012/08/28 21:53:59 UTC
git commit: WICKET-4734 don't double escape button's value
Updated Branches:
refs/heads/master 1617b5ab1 -> 55a1cb974
WICKET-4734 don't double escape button's value
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/55a1cb97
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/55a1cb97
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/55a1cb97
Branch: refs/heads/master
Commit: 55a1cb974f7247df8c4e5f8a8f8d410a9d807e3f
Parents: 1617b5a
Author: svenmeier <sv...@apache.org>
Authored: Tue Aug 28 21:51:20 2012 +0200
Committer: svenmeier <sv...@apache.org>
Committed: Tue Aug 28 21:51:20 2012 +0200
----------------------------------------------------------------------
.../org/apache/wicket/markup/html/form/Button.java | 8 +-
.../apache/wicket/markup/html/form/ButtonTest.java | 71 +++++++++++++++
.../wicket/extensions/wizard/WizardButton.java | 1 -
3 files changed, 76 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/55a1cb97/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Button.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Button.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Button.java
index 17bc33e..99dbfe5 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Button.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Button.java
@@ -65,9 +65,7 @@ public class Button extends FormComponent<String> implements IFormSubmittingComp
*/
public Button(String id)
{
- super(id);
- setVersioned(true);
- setOutputMarkupId(true);
+ this(id, null);
}
/**
@@ -86,8 +84,12 @@ public class Button extends FormComponent<String> implements IFormSubmittingComp
public Button(final String id, final IModel<String> model)
{
super(id, model);
+
setVersioned(true);
setOutputMarkupId(true);
+
+ // don't double encode the value. it is encoded by ComponentTag.writeOutput()
+ setEscapeModelStrings(false);
}
/**
http://git-wip-us.apache.org/repos/asf/wicket/blob/55a1cb97/wicket-core/src/test/java/org/apache/wicket/markup/html/form/ButtonTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/ButtonTest.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/ButtonTest.java
new file mode 100644
index 0000000..106663f
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/ButtonTest.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.wicket.markup.html.form;
+
+import org.apache.wicket.MarkupContainer;
+import org.apache.wicket.WicketTestCase;
+import org.apache.wicket.markup.IMarkupResourceStreamProvider;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.util.resource.IResourceStream;
+import org.apache.wicket.util.resource.StringResourceStream;
+import org.apache.wicket.util.string.Strings;
+import org.junit.Test;
+
+/**
+ * @author svenmeier
+ */
+public class ButtonTest extends WicketTestCase
+{
+
+ /**
+ * WICKET-4734 Asserting that the value attribute on tag input is escaped once by default
+ */
+ @Test
+ public void valueAttribute()
+ {
+ TestPage testPage = new TestPage();
+ String text = "some text & another text";
+ testPage.buttonModel.setObject(text);
+ tester.startPage(testPage);
+ assertTrue(tester.getLastResponseAsString().contains(Strings.escapeMarkup(text)));
+ }
+
+ /** */
+ public static class TestPage extends WebPage implements IMarkupResourceStreamProvider
+ {
+ private static final long serialVersionUID = 1L;
+ Form<Void> form;
+ Button button;
+ IModel<String> buttonModel = Model.of((String)null);
+
+ /** */
+ public TestPage()
+ {
+ add(form = new Form<Void>("form"));
+ form.add(button = new Button("button", buttonModel));
+ }
+
+ public IResourceStream getMarkupResourceStream(MarkupContainer container,
+ Class<?> containerClass)
+ {
+ return new StringResourceStream("<html><body>"
+ + "<form wicket:id=\"form\"><input wicket:id=\"button\" /></form></body></html>");
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/55a1cb97/wicket-extensions/src/main/java/org/apache/wicket/extensions/wizard/WizardButton.java
----------------------------------------------------------------------
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/wizard/WizardButton.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/wizard/WizardButton.java
index d3d1f26..fe21518 100644
--- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/wizard/WizardButton.java
+++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/wizard/WizardButton.java
@@ -52,7 +52,6 @@ public abstract class WizardButton extends Button
{
super(id, new ResourceModel(labelResourceKey));
this.wizard = wizard;
- setEscapeModelStrings(false);
}
/**