diff options
Diffstat (limited to 'juick-crosspost')
-rw-r--r-- | juick-crosspost/src/main/java/com/juick/components/Crosspost.java | 9 | ||||
-rw-r--r-- | juick-crosspost/src/main/java/com/juick/components/configuration/CrosspostInitializer.java | 5 |
2 files changed, 7 insertions, 7 deletions
diff --git a/juick-crosspost/src/main/java/com/juick/components/Crosspost.java b/juick-crosspost/src/main/java/com/juick/components/Crosspost.java index 6daa8ddd9..5e28c71ec 100644 --- a/juick-crosspost/src/main/java/com/juick/components/Crosspost.java +++ b/juick-crosspost/src/main/java/com/juick/components/Crosspost.java @@ -21,6 +21,7 @@ import com.juick.Tag; import com.juick.service.CrosspostService; import org.apache.commons.codec.binary.Base64; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.CharEncoding; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.apache.commons.lang3.tuple.Pair; @@ -83,7 +84,7 @@ public class Crosspost implements AutoCloseable { public static String percentEncode(final String s) { String ret = ""; try { - ret = URLEncoder.encode(s, "UTF-8").replace("+", "%20").replace("*", "%2A").replace("%7E", "~"); + ret = URLEncoder.encode(s, CharEncoding.UTF_8).replace("+", "%20").replace("*", "%2A").replace("%7E", "~"); } catch (UnsupportedEncodingException e) { } return ret; @@ -136,9 +137,9 @@ public class Crosspost implements AutoCloseable { boolean ret = false; try { String body = "access_token=" - + URLEncoder.encode(token, "UTF-8") + + URLEncoder.encode(token, CharEncoding.UTF_8) + "&message=" - + URLEncoder.encode(status, "UTF-8") + + URLEncoder.encode(status, CharEncoding.UTF_8) + "&link=http%3A%2F%2Fjuick.com%2F" + jmsg.getMid(); @@ -177,7 +178,7 @@ public class Crosspost implements AutoCloseable { boolean ret = false; try { - String body = "owner_id=" + tokens.getLeft() + "&access_token=" + URLEncoder.encode(tokens.getRight(), "UTF-8") + "&from_group=1&message=" + URLEncoder.encode(status, "UTF-8"); + String body = "owner_id=" + tokens.getLeft() + "&access_token=" + URLEncoder.encode(tokens.getRight(), CharEncoding.UTF_8) + "&from_group=1&message=" + URLEncoder.encode(status, CharEncoding.UTF_8); HttpsURLConnection conn = (HttpsURLConnection) new URL(VKURL).openConnection(); conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); diff --git a/juick-crosspost/src/main/java/com/juick/components/configuration/CrosspostInitializer.java b/juick-crosspost/src/main/java/com/juick/components/configuration/CrosspostInitializer.java index baedfa297..d486e2017 100644 --- a/juick-crosspost/src/main/java/com/juick/components/configuration/CrosspostInitializer.java +++ b/juick-crosspost/src/main/java/com/juick/components/configuration/CrosspostInitializer.java @@ -1,6 +1,7 @@ package com.juick.components.configuration; import com.juick.configuration.DataConfiguration; +import org.apache.commons.lang3.CharEncoding; import org.springframework.web.filter.CharacterEncodingFilter; import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; @@ -28,9 +29,7 @@ public class CrosspostInitializer extends AbstractAnnotationConfigDispatcherServ @Override protected Filter[] getServletFilters() { - CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(); - characterEncodingFilter.setEncoding("UTF-8"); - + CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(CharEncoding.UTF_8); return new Filter[]{characterEncodingFilter}; } |