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 2018/07/22 16:42:47 UTC
[1/2] wicket git commit: WICKET-6568 escape header
"Wicket-FocusedElementId"
Repository: wicket
Updated Branches:
refs/heads/WICKET-6563 e3c14f49c -> 409cef886
WICKET-6568 escape header "Wicket-FocusedElementId"
it might contain non-ASCII
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/f6a195d3
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/f6a195d3
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/f6a195d3
Branch: refs/heads/WICKET-6563
Commit: f6a195d346758ceed155ffc87074780b48d3dfbe
Parents: e3c14f4
Author: Sven Meier <sv...@apache.org>
Authored: Thu Jul 19 18:52:55 2018 +0200
Committer: Sven Meier <sv...@apache.org>
Committed: Thu Jul 19 18:57:59 2018 +0200
----------------------------------------------------------------------
.../main/java/org/apache/wicket/ajax/AjaxRequestHandler.java | 6 +++++-
.../java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js | 3 ++-
2 files changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/f6a195d3/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestHandler.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestHandler.java b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestHandler.java
index 63bca5f..c67f8ba 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestHandler.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestHandler.java
@@ -45,6 +45,7 @@ import org.apache.wicket.request.http.WebResponse;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.response.StringResponse;
import org.apache.wicket.response.filter.IResponseFilter;
+import org.apache.wicket.util.encoding.UrlDecoder;
import org.apache.wicket.util.lang.Args;
import org.apache.wicket.util.lang.Classes;
import org.apache.wicket.util.string.AppendingStringBuffer;
@@ -451,8 +452,11 @@ public class AjaxRequestHandler implements AjaxRequestTarget
public String getLastFocusedElementId()
{
WebRequest request = (WebRequest)page.getRequest();
+
String id = request.getHeader("Wicket-FocusedElementId");
- return Strings.isEmpty(id) ? null : id;
+
+ // WICKET-6568 might contain non-ASCII
+ return Strings.isEmpty(id) ? null : UrlDecoder.QUERY_INSTANCE.decode(id, request.getCharset());
}
@Override
http://git-wip-us.apache.org/repos/asf/wicket/blob/f6a195d3/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
index 6a3a45b..8bef057 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
@@ -600,7 +600,8 @@
topic = we.Topic;
if (Wicket.Focus.lastFocusId) {
- headers["Wicket-FocusedElementId"] = Wicket.Focus.lastFocusId;
+ // WICKET-6568 might contain non-ASCII
+ headers["Wicket-FocusedElementId"] = Wicket.Form.encode(Wicket.Focus.lastFocusId);
}
self._executeHandlers(attrs.bh, attrs);
[2/2] wicket git commit: WICKET-6568 added test
Posted by sv...@apache.org.
WICKET-6568 added test
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/409cef88
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/409cef88
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/409cef88
Branch: refs/heads/WICKET-6563
Commit: 409cef886cfd5ae70261dfcbb369038796a9767a
Parents: f6a195d
Author: Sven Meier <sv...@apache.org>
Authored: Sun Jul 22 17:35:27 2018 +0200
Committer: Sven Meier <sv...@apache.org>
Committed: Sun Jul 22 17:36:09 2018 +0200
----------------------------------------------------------------------
.../wicket/ajax/AjaxRequestHandlerTest.java | 21 ++++++++++
.../java/org/apache/wicket/ajax/FocusPage.html | 6 +++
.../java/org/apache/wicket/ajax/FocusPage.java | 40 ++++++++++++++++++++
3 files changed, 67 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/409cef88/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxRequestHandlerTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxRequestHandlerTest.java b/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxRequestHandlerTest.java
index 90b35f6..8c90304 100644
--- a/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxRequestHandlerTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxRequestHandlerTest.java
@@ -18,6 +18,7 @@ package org.apache.wicket.ajax;
import java.io.IOException;
import java.lang.reflect.Constructor;
+import java.nio.charset.Charset;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -30,6 +31,7 @@ import org.apache.wicket.event.IEvent;
import org.apache.wicket.markup.IMarkupResourceStreamProvider;
import org.apache.wicket.markup.html.WebComponent;
import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.util.encoding.UrlEncoder;
import org.apache.wicket.util.resource.IResourceStream;
import org.apache.wicket.util.resource.StringResourceStream;
import org.apache.wicket.util.tester.DiffUtil;
@@ -181,6 +183,25 @@ public class AjaxRequestHandlerTest extends WicketTestCase
}
/**
+ * WICKET-6568
+ */
+ @Test
+ public void lastFocusedEncoding()
+ {
+ FocusPage page = new FocusPage();
+
+ tester.startPage(page);
+
+ // wicket-ajax-jquery encodes non ASCII id
+ String encoded = UrlEncoder.QUERY_INSTANCE.encode("€uro", Charset.forName("UTF-8"));
+ tester.getRequest().setHeader("Wicket-FocusedElementId", encoded);
+
+ tester.executeAjaxEvent("link", "click");
+
+ assertEquals("€uro", page.lastFocusedElementId);
+ }
+
+ /**
* WICKET-2543
*/
@Test
http://git-wip-us.apache.org/repos/asf/wicket/blob/409cef88/wicket-core/src/test/java/org/apache/wicket/ajax/FocusPage.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/ajax/FocusPage.html b/wicket-core/src/test/java/org/apache/wicket/ajax/FocusPage.html
new file mode 100644
index 0000000..b6b9b35
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/ajax/FocusPage.html
@@ -0,0 +1,6 @@
+<html>
+ <body>
+ <a wicket:id="link"></a>
+ </body>
+</html>
+
http://git-wip-us.apache.org/repos/asf/wicket/blob/409cef88/wicket-core/src/test/java/org/apache/wicket/ajax/FocusPage.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/ajax/FocusPage.java b/wicket-core/src/test/java/org/apache/wicket/ajax/FocusPage.java
new file mode 100644
index 0000000..8f94d73
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/ajax/FocusPage.java
@@ -0,0 +1,40 @@
+/*
+ * 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.ajax;
+
+import org.apache.wicket.ajax.markup.html.AjaxLink;
+import org.apache.wicket.markup.html.WebPage;
+
+/**
+ */
+public class FocusPage extends WebPage
+{
+ private static final long serialVersionUID = 1L;
+
+ public String lastFocusedElementId;
+
+ public FocusPage( ) {
+ add(new AjaxLink<Void>("link")
+ {
+ @Override
+ public void onClick(AjaxRequestTarget target)
+ {
+ lastFocusedElementId = target.getLastFocusedElementId();
+ }
+ });
+ }
+}