]> source.dussan.org Git - gitblit.git/commitdiff
replaced WicketURL[En/De]coder with Url[En/De]coder
authorMartin Spielmann <martin.spielmann@pingunaut.com>
Sat, 30 Jul 2016 09:26:34 +0000 (11:26 +0200)
committerMartin Spielmann <martin.spielmann@pingunaut.com>
Sat, 30 Jul 2016 09:26:34 +0000 (11:26 +0200)
src/main/java/com/gitblit/wicket/MarkupProcessor.java
src/main/java/com/gitblit/wicket/SessionlessForm.java
src/main/java/com/gitblit/wicket/pages/ImageDiffHandler.java
src/main/java/com/gitblit/wicket/pages/RawPage.java
src/main/java/com/gitblit/wicket/panels/BranchesPanel.java
src/main/java/com/gitblit/wicket/panels/TagsPanel.java

index 50d64697470389f627f14291a65a1f2581527566..40cf95604c582938092533fe8e21c817fdec1575 100644 (file)
@@ -53,6 +53,7 @@ import org.pegdown.plugins.ToHtmlSerializerPlugin;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.gitblit.Constants;
 import com.gitblit.IStoredSettings;
 import com.gitblit.Keys;
 import com.gitblit.models.PathModel;
@@ -369,7 +370,7 @@ public class MarkupProcessor {
                String fsc = settings.getString(Keys.web.forwardSlashCharacter, "/");
                String encodedPath = document.replace(' ', '-');
                try {
-                       encodedPath = URLEncoder.encode(encodedPath, "UTF-8");
+                       encodedPath = URLEncoder.encode(encodedPath, Constants.ENCODING);
                } catch (UnsupportedEncodingException e) {
                        logger.error(null, e);
                }
index 93a8d0fe6248260313739f51424be02aff05bda0..d3a9c9c3a334c4f678f51934017131cdd661cd62 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.gitblit.wicket;
 
+import java.nio.charset.StandardCharsets;
 import java.text.MessageFormat;
 
 import org.apache.wicket.Component;
@@ -22,14 +23,13 @@ import org.apache.wicket.request.mapper.parameter.PageParameters;
 import org.apache.wicket.markup.ComponentTag;
 import org.apache.wicket.markup.MarkupStream;
 import org.apache.wicket.markup.html.form.StatelessForm;
-import org.apache.wicket.protocol.http.RequestUtils;
-//import org.apache.wicket.protocol.http.WicketURLDecoder;
-//import org.apache.wicket.protocol.http.request.WebRequestCodingStrategy;
+import org.apache.wicket.util.encoding.UrlDecoder;
 import org.apache.wicket.util.string.AppendingStringBuffer;
 import org.apache.wicket.util.string.Strings;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.gitblit.Constants;
 import com.gitblit.utils.GitBlitRequestUtils;
 import com.gitblit.wicket.pages.BasePage;
 
@@ -106,7 +106,7 @@ public class SessionlessForm<T> extends StatelessForm<T> {
                // render the hidden bookmarkable page field
                AppendingStringBuffer buffer = new AppendingStringBuffer(HIDDEN_DIV_START);
                buffer.append("<input type=\"hidden\" name=\"")
-                       .append(WebRequestCodingStrategy.BOOKMARKABLE_PAGE_PARAMETER_NAME)
+                       .append("wicket:bookmarkablePage")
                        .append("\" value=\":")
                        .append(pageClass.getName())
                        .append("\" />");
@@ -114,7 +114,7 @@ public class SessionlessForm<T> extends StatelessForm<T> {
                // insert the page parameters, if any, as hidden fields as long as they
                // do not collide with any child wicket:id of the form.
                if (pageParameters != null) {
-                       for (String key : pageParameters.keySet()) {
+                       for (String key : pageParameters.getNamedKeys()) {
                                Component c = get(key);
                                if (c != null) {
                                        // this form has a field id which matches the
@@ -122,7 +122,7 @@ public class SessionlessForm<T> extends StatelessForm<T> {
                                        log.warn(MessageFormat.format("Skipping page parameter \"{0}\" from sessionless form hidden fields because it collides with a form child wicket:id", key));
                                        continue;
                                }
-                               String value = pageParameters.getString(key);
+                               String value = pageParameters.get(key).toString();
                                buffer.append("<input type=\"hidden\" name=\"")
                                .append(recode(key))
                                .append("\" value=\"")
@@ -144,7 +144,7 @@ public class SessionlessForm<T> extends StatelessForm<T> {
         * @return reencoded value
         */
        private String recode(String s) {
-               String un = WicketURLDecoder.QUERY_INSTANCE.decode(s);
+               String un = UrlDecoder.QUERY_INSTANCE.decode(s, Constants.ENCODING);
                return Strings.escapeMarkup(un).toString();
        }
 
index cc06f44b2cc23768ceb83fe77847f9d1aba84ce6..bdd33b9c27e18079dd7bc388d1065274f7558304 100644 (file)
@@ -19,11 +19,13 @@ import java.nio.charset.StandardCharsets;
 import java.util.List;
 
 import org.apache.wicket.protocol.http.WebApplication;
-//import org.apache.wicket.protocol.http.WicketURLEncoder;
+import org.apache.wicket.util.encoding.UrlDecoder;
+import org.apache.wicket.util.encoding.UrlEncoder;
 import org.eclipse.jgit.diff.DiffEntry;
 import org.eclipse.jgit.diff.DiffEntry.Side;
 import org.jsoup.nodes.Element;
 
+import com.gitblit.Constants;
 import com.gitblit.servlet.RawServlet;
 import com.gitblit.utils.DiffUtils;
 import com.gitblit.utils.HtmlBuilder;
@@ -165,6 +167,6 @@ public class ImageDiffHandler implements DiffUtils.BinaryDiffHandler {
                // Actually, this should be done in RawServlet.asLink(). As it is now, this may be incorrect if that
                // operation ever uses query parameters instead of paths, or if it is fixed to urlencode its path
                // components. But I don't want to touch that static method in RawServlet.
-               return WicketURLEncoder.PATH_INSTANCE.encode(component, StandardCharsets.UTF_8.name()).replaceAll("%2[fF]", "/");
+               return UrlEncoder.PATH_INSTANCE.encode(component, Constants.ENCODING).replaceAll("%2[fF]", "/");
        }
 }
index 5f94198eaad6d7a95cc421fa639b9b91e2461f60..10c98fcdd6db3653dd2dff7885fd359e31db37a7 100644 (file)
@@ -34,6 +34,7 @@ import org.eclipse.jgit.revwalk.RevCommit;
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 \r
+import com.gitblit.Constants;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.models.UserModel;\r
@@ -177,13 +178,13 @@ public class RawPage extends SessionPage {
 \r
                                                                if (userAgent != null && userAgent.indexOf("MSIE 5.5") > -1) {\r
                                                                      response.setHeader("Content-Disposition", "filename=\""\r
-                                                                                 +  URLEncoder.encode(filename, "UTF-8") + "\"");\r
+                                                                                 +  URLEncoder.encode(filename, Constants.ENCODING) + "\"");\r
                                                                } else if (userAgent != null && userAgent.indexOf("MSIE") > -1) {\r
                                                                      response.setHeader("Content-Disposition", "attachment; filename=\""\r
-                                                                                 +  URLEncoder.encode(filename, "UTF-8") + "\"");\r
+                                                                                 +  URLEncoder.encode(filename, Constants.ENCODING) + "\"");\r
                                                                } else {\r
                                                                                response.setHeader("Content-Disposition", "attachment; filename=\""\r
-                                                                                     + new String(filename.getBytes("UTF-8"), "latin1") + "\"");\r
+                                                                                     + new String(filename.getBytes(Constants.ENCODING), "latin1") + "\"");\r
                                                                }\r
                                                        }\r
                                                        catch (UnsupportedEncodingException e) {\r
index 07cdafd56053a3c69ec8a6a05ef644b060ec4210..d5dc1a37619becccb2b945b96070b988e2453ad6 100644 (file)
@@ -32,7 +32,6 @@ import org.apache.wicket.markup.repeater.Item;
 import org.apache.wicket.markup.repeater.data.DataView;\r
 import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
 import org.apache.wicket.model.StringResourceModel;\r
-import org.apache.wicket.protocol.http.RequestUtils;\r
 import org.eclipse.jgit.lib.Ref;\r
 import org.eclipse.jgit.lib.Repository;\r
 \r
index a681e6ce0743abf2bce46c58653cb7015a68ab86..9926d1132eec23886a42577816a2208b5accbd4c 100644 (file)
@@ -26,7 +26,6 @@ import org.apache.wicket.markup.repeater.Item;
 import org.apache.wicket.markup.repeater.data.DataView;\r
 import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
 import org.apache.wicket.model.StringResourceModel;\r
-import org.apache.wicket.request.cycle.RequestCycle;\r
 import org.eclipse.jgit.lib.Constants;\r
 import org.eclipse.jgit.lib.Repository;\r
 \r