diff options
author | Martin Spielmann <martin.spielmann@pingunaut.com> | 2016-07-30 11:26:34 +0200 |
---|---|---|
committer | Martin Spielmann <martin.spielmann@pingunaut.com> | 2016-07-30 11:26:34 +0200 |
commit | 82046303f0f99b28b97cd7173d2fd94724c477d4 (patch) | |
tree | 9d8eb245d0ff8ff3038b736a4a639e31c577bfeb /src | |
parent | f03cf597771e0efb4bdd6bb1665d83e67f9bbaab (diff) | |
download | gitblit-82046303f0f99b28b97cd7173d2fd94724c477d4.tar.gz gitblit-82046303f0f99b28b97cd7173d2fd94724c477d4.zip |
replaced WicketURL[En/De]coder with Url[En/De]coder
Diffstat (limited to 'src')
6 files changed, 17 insertions, 15 deletions
diff --git a/src/main/java/com/gitblit/wicket/MarkupProcessor.java b/src/main/java/com/gitblit/wicket/MarkupProcessor.java index 50d64697..40cf9560 100644 --- a/src/main/java/com/gitblit/wicket/MarkupProcessor.java +++ b/src/main/java/com/gitblit/wicket/MarkupProcessor.java @@ -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); } diff --git a/src/main/java/com/gitblit/wicket/SessionlessForm.java b/src/main/java/com/gitblit/wicket/SessionlessForm.java index 93a8d0fe..d3a9c9c3 100644 --- a/src/main/java/com/gitblit/wicket/SessionlessForm.java +++ b/src/main/java/com/gitblit/wicket/SessionlessForm.java @@ -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(); } diff --git a/src/main/java/com/gitblit/wicket/pages/ImageDiffHandler.java b/src/main/java/com/gitblit/wicket/pages/ImageDiffHandler.java index cc06f44b..bdd33b9c 100644 --- a/src/main/java/com/gitblit/wicket/pages/ImageDiffHandler.java +++ b/src/main/java/com/gitblit/wicket/pages/ImageDiffHandler.java @@ -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]", "/"); } } diff --git a/src/main/java/com/gitblit/wicket/pages/RawPage.java b/src/main/java/com/gitblit/wicket/pages/RawPage.java index 5f94198e..10c98fcd 100644 --- a/src/main/java/com/gitblit/wicket/pages/RawPage.java +++ b/src/main/java/com/gitblit/wicket/pages/RawPage.java @@ -34,6 +34,7 @@ import org.eclipse.jgit.revwalk.RevCommit; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.gitblit.Constants;
import com.gitblit.Keys;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.UserModel;
@@ -177,13 +178,13 @@ public class RawPage extends SessionPage { if (userAgent != null && userAgent.indexOf("MSIE 5.5") > -1) {
response.setHeader("Content-Disposition", "filename=\""
- + URLEncoder.encode(filename, "UTF-8") + "\"");
+ + URLEncoder.encode(filename, Constants.ENCODING) + "\"");
} else if (userAgent != null && userAgent.indexOf("MSIE") > -1) {
response.setHeader("Content-Disposition", "attachment; filename=\""
- + URLEncoder.encode(filename, "UTF-8") + "\"");
+ + URLEncoder.encode(filename, Constants.ENCODING) + "\"");
} else {
response.setHeader("Content-Disposition", "attachment; filename=\""
- + new String(filename.getBytes("UTF-8"), "latin1") + "\"");
+ + new String(filename.getBytes(Constants.ENCODING), "latin1") + "\"");
}
}
catch (UnsupportedEncodingException e) {
diff --git a/src/main/java/com/gitblit/wicket/panels/BranchesPanel.java b/src/main/java/com/gitblit/wicket/panels/BranchesPanel.java index 07cdafd5..d5dc1a37 100644 --- a/src/main/java/com/gitblit/wicket/panels/BranchesPanel.java +++ b/src/main/java/com/gitblit/wicket/panels/BranchesPanel.java @@ -32,7 +32,6 @@ import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
import org.apache.wicket.model.StringResourceModel;
-import org.apache.wicket.protocol.http.RequestUtils;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
diff --git a/src/main/java/com/gitblit/wicket/panels/TagsPanel.java b/src/main/java/com/gitblit/wicket/panels/TagsPanel.java index a681e6ce..9926d113 100644 --- a/src/main/java/com/gitblit/wicket/panels/TagsPanel.java +++ b/src/main/java/com/gitblit/wicket/panels/TagsPanel.java @@ -26,7 +26,6 @@ import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
import org.apache.wicket.model.StringResourceModel;
-import org.apache.wicket.request.cycle.RequestCycle;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;
|