aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--juick-api/src/main/java/com/juick/api/configuration/ApiInitializer.java4
-rw-r--r--juick-crosspost/src/main/java/com/juick/components/Crosspost.java9
-rw-r--r--juick-crosspost/src/main/java/com/juick/components/configuration/CrosspostInitializer.java5
-rw-r--r--juick-notifications/src/main/java/com/juick/components/configuration/NotificationsInitializer.java4
-rw-r--r--juick-rss/src/main/java/com/juick/rss/configuration/RssInitializer.java4
-rw-r--r--juick-spring-www/src/main/java/com/juick/www/configuration/WebAppConfiguration.java3
-rw-r--r--juick-spring-www/src/main/java/com/juick/www/configuration/WwwInitializer.java3
-rw-r--r--juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java5
-rw-r--r--juick-spring-www/src/main/java/com/juick/www/controllers/IndexController.java3
-rw-r--r--juick-spring-www/src/main/java/com/juick/www/controllers/TagController.java7
-rw-r--r--juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java3
-rw-r--r--juick-ws/src/main/java/com/juick/ws/configuration/WebsocketInitializer.java3
-rw-r--r--juick-www/src/main/java/com/juick/www/Discover.java9
-rw-r--r--juick-www/src/main/java/com/juick/www/FacebookLogin.java5
-rw-r--r--juick-www/src/main/java/com/juick/www/Home.java3
-rw-r--r--juick-www/src/main/java/com/juick/www/Main.java7
-rw-r--r--juick-www/src/main/java/com/juick/www/NewMessage.java11
-rw-r--r--juick-www/src/main/java/com/juick/www/PageTemplates.java3
-rw-r--r--juick-www/src/main/java/com/juick/www/User.java11
-rw-r--r--juick-www/src/main/java/com/juick/www/VKontakteLogin.java5
-rw-r--r--juick-xmpp-bot/src/main/java/com/juick/components/configuration/BotInitializer.java4
-rw-r--r--juick-xmpp-ft/src/main/java/com/juick/components/configuration/FileTransferInitializer.java4
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/configuration/XmppInitializer.java5
-rw-r--r--src/test/java/com/juick/rss/LegacyRSS.java3
-rw-r--r--src/test/java/com/juick/tests/MessageTests.java3
25 files changed, 71 insertions, 55 deletions
diff --git a/juick-api/src/main/java/com/juick/api/configuration/ApiInitializer.java b/juick-api/src/main/java/com/juick/api/configuration/ApiInitializer.java
index 63ba52e8..41fe8b2d 100644
--- a/juick-api/src/main/java/com/juick/api/configuration/ApiInitializer.java
+++ b/juick-api/src/main/java/com/juick/api/configuration/ApiInitializer.java
@@ -1,7 +1,7 @@
package com.juick.api.configuration;
import com.juick.configuration.DataConfiguration;
-import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer;
+import org.apache.commons.lang3.CharEncoding;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
@@ -29,7 +29,7 @@ public class ApiInitializer extends AbstractAnnotationConfigDispatcherServletIni
@Override
protected Filter[] getServletFilters() {
- return new Filter[]{new CharacterEncodingFilter("UTF-8")};
+ return new Filter[]{new CharacterEncodingFilter(CharEncoding.UTF_8)};
}
@Override
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 6daa8ddd..5e28c71e 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 baedfa29..d486e201 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};
}
diff --git a/juick-notifications/src/main/java/com/juick/components/configuration/NotificationsInitializer.java b/juick-notifications/src/main/java/com/juick/components/configuration/NotificationsInitializer.java
index ddd734d1..617f8686 100644
--- a/juick-notifications/src/main/java/com/juick/components/configuration/NotificationsInitializer.java
+++ b/juick-notifications/src/main/java/com/juick/components/configuration/NotificationsInitializer.java
@@ -1,5 +1,6 @@
package com.juick.components.configuration;
+import org.apache.commons.lang3.CharEncoding;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
@@ -27,8 +28,7 @@ public class NotificationsInitializer extends AbstractAnnotationConfigDispatcher
@Override
protected Filter[] getServletFilters() {
- CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
- characterEncodingFilter.setEncoding("UTF-8");
+ CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(CharEncoding.UTF_8);
return new Filter[]{characterEncodingFilter};
}
diff --git a/juick-rss/src/main/java/com/juick/rss/configuration/RssInitializer.java b/juick-rss/src/main/java/com/juick/rss/configuration/RssInitializer.java
index a66fcca7..2dd6d117 100644
--- a/juick-rss/src/main/java/com/juick/rss/configuration/RssInitializer.java
+++ b/juick-rss/src/main/java/com/juick/rss/configuration/RssInitializer.java
@@ -1,6 +1,7 @@
package com.juick.rss.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,8 +29,7 @@ public class RssInitializer extends AbstractAnnotationConfigDispatcherServletIni
@Override
protected Filter[] getServletFilters() {
- CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
- characterEncodingFilter.setEncoding("UTF-8");
+ CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(CharEncoding.UTF_8);
return new Filter[]{characterEncodingFilter};
}
diff --git a/juick-spring-www/src/main/java/com/juick/www/configuration/WebAppConfiguration.java b/juick-spring-www/src/main/java/com/juick/www/configuration/WebAppConfiguration.java
index 28a0f29a..4482dce1 100644
--- a/juick-spring-www/src/main/java/com/juick/www/configuration/WebAppConfiguration.java
+++ b/juick-spring-www/src/main/java/com/juick/www/configuration/WebAppConfiguration.java
@@ -2,6 +2,7 @@ package com.juick.www.configuration;
import com.juick.www.HelpService;
import com.juick.www.WebApp;
+import org.apache.commons.lang3.CharEncoding;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.guava.GuavaCacheManager;
import org.springframework.cache.interceptor.KeyGenerator;
@@ -29,7 +30,7 @@ public class WebAppConfiguration {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasenames("messages", "errors");
- messageSource.setDefaultEncoding("UTF-8");
+ messageSource.setDefaultEncoding(CharEncoding.UTF_8);
messageSource.setFallbackToSystemLocale(false);
messageSource.setUseCodeAsDefaultMessage(true);
diff --git a/juick-spring-www/src/main/java/com/juick/www/configuration/WwwInitializer.java b/juick-spring-www/src/main/java/com/juick/www/configuration/WwwInitializer.java
index edb9a9fc..33687983 100644
--- a/juick-spring-www/src/main/java/com/juick/www/configuration/WwwInitializer.java
+++ b/juick-spring-www/src/main/java/com/juick/www/configuration/WwwInitializer.java
@@ -2,6 +2,7 @@ package com.juick.www.configuration;
import com.juick.configuration.DataConfiguration;
import com.juick.configuration.SearchConfiguration;
+import org.apache.commons.lang3.CharEncoding;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
@@ -43,7 +44,7 @@ public class WwwInitializer extends AbstractAnnotationConfigDispatcherServletIni
super.onStartup(servletContext);
FilterRegistration.Dynamic registration = servletContext.addFilter(
- "encodingFilter", new CharacterEncodingFilter("UTF-8", true));
+ "encodingFilter", new CharacterEncodingFilter(CharEncoding.UTF_8, true));
registration.addMappingForUrlPatterns(null, true, "/*");
}
diff --git a/juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java b/juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java
index 15f85c9a..5cd251e6 100644
--- a/juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java
+++ b/juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.juick.www.formatter.SpringDateFormatter;
import nz.net.ultraq.thymeleaf.LayoutDialect;
import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.CharEncoding;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@@ -55,7 +56,7 @@ public class WwwServletConfiguration extends WebMvcConfigurationSupport {
// templates to be automatically updated when modified.
templateResolver.setCacheable(true);
- templateResolver.setCharacterEncoding("UTF-8");
+ templateResolver.setCharacterEncoding(CharEncoding.UTF_8);
return templateResolver;
}
@@ -83,7 +84,7 @@ public class WwwServletConfiguration extends WebMvcConfigurationSupport {
public ThymeleafViewResolver viewResolver() {
ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
viewResolver.setTemplateEngine(templateEngine());
- viewResolver.setCharacterEncoding("UTF-8");
+ viewResolver.setCharacterEncoding(CharEncoding.UTF_8);
viewResolver.addStaticVariable(
"showSape", BooleanUtils.toBoolean(env.getProperty("template.showSape", "true")));
diff --git a/juick-spring-www/src/main/java/com/juick/www/controllers/IndexController.java b/juick-spring-www/src/main/java/com/juick/www/controllers/IndexController.java
index ffc64221..54d83b61 100644
--- a/juick-spring-www/src/main/java/com/juick/www/controllers/IndexController.java
+++ b/juick-spring-www/src/main/java/com/juick/www/controllers/IndexController.java
@@ -7,6 +7,7 @@ import com.juick.service.TagService;
import com.juick.service.UserService;
import com.juick.util.UserUtils;
import com.juick.www.util.EncodeUtils;
+import org.apache.commons.lang3.CharEncoding;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.MessageSource;
@@ -48,7 +49,7 @@ public class IndexController {
ModelMap model) throws IOException {
if (paramTagStr.isPresent())
- return "redirect:/tag/" + URLEncoder.encode(paramTagStr.get(), "UTF-8");
+ return "redirect:/tag/" + URLEncoder.encode(paramTagStr.get(), CharEncoding.UTF_8);
if (StringUtils.isNotEmpty(paramSearch) && paramSearch.length() > 64)
paramSearch = "";
diff --git a/juick-spring-www/src/main/java/com/juick/www/controllers/TagController.java b/juick-spring-www/src/main/java/com/juick/www/controllers/TagController.java
index 69688513..8c4ab46d 100644
--- a/juick-spring-www/src/main/java/com/juick/www/controllers/TagController.java
+++ b/juick-spring-www/src/main/java/com/juick/www/controllers/TagController.java
@@ -9,6 +9,7 @@ import com.juick.service.TagService;
import com.juick.service.UserService;
import com.juick.util.UserUtils;
import com.juick.www.helpers.QueryString;
+import org.apache.commons.lang3.CharEncoding;
import org.apache.commons.lang3.StringEscapeUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
@@ -51,13 +52,13 @@ public class TagController {
throw new HttpNotFoundException();
} else if (paramTag.SynonymID > 0 && paramTag.TID != paramTag.SynonymID) {
com.juick.Tag synTag = tagService.getTag(paramTag.SynonymID);
- String url = "/tag/" + URLEncoder.encode(synTag.getName(), "UTF-8");
+ String url = "/tag/" + URLEncoder.encode(synTag.getName(), CharEncoding.UTF_8);
if (queryString.isPresent()) {
url += "?" + queryString.get();
}
return "redirect:" + url;
} else if (!paramTag.getName().equals(paramTagStr)) {
- String url = "/tag/" + URLEncoder.encode(paramTag.getName(), "UTF-8");
+ String url = "/tag/" + URLEncoder.encode(paramTag.getName(), CharEncoding.UTF_8);
if (queryString.isPresent()) {
url += "?" + queryString.get();
}
@@ -97,7 +98,7 @@ public class TagController {
}).collect(Collectors.toList())
);
if (mids.size() >= 20) {
- String nextpage = "/tag/" + URLEncoder.encode(paramTag.getName(), "UTF-8") + "?before=" + mids.get(mids.size() - 1);
+ String nextpage = "/tag/" + URLEncoder.encode(paramTag.getName(), CharEncoding.UTF_8) + "?before=" + mids.get(mids.size() - 1);
model.addAttribute("nextpage", nextpage);
}
model.addAttribute("tags", tagService.getPopularTags());
diff --git a/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java b/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java
index 85f936b5..c73c50e5 100644
--- a/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java
+++ b/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java
@@ -3,6 +3,7 @@ package com.juick.ws;
import com.juick.User;
import com.juick.service.MessagesService;
import com.juick.service.UserService;
+import org.apache.commons.lang3.CharEncoding;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URLEncodedUtils;
@@ -45,7 +46,7 @@ public class WebsocketComponent extends TextWebSocketHandler {
// Auth
User visitor = new User();
- List<NameValuePair> params = URLEncodedUtils.parse(hLocation, "UTF-8");
+ List<NameValuePair> params = URLEncodedUtils.parse(hLocation, CharEncoding.UTF_8);
for (NameValuePair param : params) {
if (param.getName().equals("hash")) {
String hash = param.getValue();
diff --git a/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketInitializer.java b/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketInitializer.java
index 6feea4c7..ed6b1069 100644
--- a/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketInitializer.java
+++ b/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketInitializer.java
@@ -1,6 +1,7 @@
package com.juick.ws.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,7 +29,7 @@ public class WebsocketInitializer extends AbstractAnnotationConfigDispatcherServ
@Override
protected Filter[] getServletFilters() {
- return new Filter[]{new CharacterEncodingFilter("UTF-8")};
+ return new Filter[]{new CharacterEncodingFilter(CharEncoding.UTF_8)};
}
@Override
diff --git a/juick-www/src/main/java/com/juick/www/Discover.java b/juick-www/src/main/java/com/juick/www/Discover.java
index 860ad893..9cfad874 100644
--- a/juick-www/src/main/java/com/juick/www/Discover.java
+++ b/juick-www/src/main/java/com/juick/www/Discover.java
@@ -20,6 +20,7 @@ package com.juick.www;
import com.juick.server.AdsQueries;
import com.juick.server.MessagesQueries;
import com.juick.server.TagQueries;
+import org.apache.commons.lang3.CharEncoding;
import org.apache.commons.lang3.StringEscapeUtils;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -41,21 +42,21 @@ public class Discover {
protected void doGet(JdbcTemplate sql, JdbcTemplate sqlSearch, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
- String paramTagStr = URLDecoder.decode(request.getRequestURI().substring(5), "UTF-8");
+ String paramTagStr = URLDecoder.decode(request.getRequestURI().substring(5), CharEncoding.UTF_8);
com.juick.Tag paramTag = TagQueries.getTag(sql, paramTagStr, false);
if (paramTag == null) {
Errors.doGet404(sql, request, response);
return;
} else if (paramTag.SynonymID > 0 && paramTag.TID != paramTag.SynonymID) {
com.juick.Tag synTag = TagQueries.getTag(sql, paramTag.SynonymID);
- String url = "/tag/" + URLEncoder.encode(synTag.getName(), "UTF-8");
+ String url = "/tag/" + URLEncoder.encode(synTag.getName(), CharEncoding.UTF_8);
if (request.getQueryString() != null) {
url += "?" + request.getQueryString();
}
Utils.sendPermanentRedirect(response, url);
return;
} else if (!paramTag.getName().equals(paramTagStr)) {
- String url = "/tag/" + URLEncoder.encode(paramTag.getName(), "UTF-8");
+ String url = "/tag/" + URLEncoder.encode(paramTag.getName(), CharEncoding.UTF_8);
if (request.getQueryString() != null) {
url += "?" + request.getQueryString();
}
@@ -104,7 +105,7 @@ public class Discover {
}
if (mids.size() >= 20) {
- String nextpage = "/tag/" + URLEncoder.encode(paramTag.getName(), "UTF-8") + "?before=" + mids.get(mids.size() - 1);
+ String nextpage = "/tag/" + URLEncoder.encode(paramTag.getName(), CharEncoding.UTF_8) + "?before=" + mids.get(mids.size() - 1);
out.println("<p class=\"page\"><a href=\"" + nextpage + "\" rel=\"prev\">Читать дальше →</a></p>");
}
diff --git a/juick-www/src/main/java/com/juick/www/FacebookLogin.java b/juick-www/src/main/java/com/juick/www/FacebookLogin.java
index e9c4b786..1dcbb39f 100644
--- a/juick-www/src/main/java/com/juick/www/FacebookLogin.java
+++ b/juick-www/src/main/java/com/juick/www/FacebookLogin.java
@@ -21,6 +21,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.juick.server.UserQueries;
import com.juick.www.facebook.Graph;
+import org.apache.commons.lang3.CharEncoding;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.Logger;
@@ -69,7 +70,7 @@ public class FacebookLogin {
response.addCookie(c);
response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
- response.setHeader("Location", "https://www.facebook.com/dialog/oauth?scope=publish_stream&client_id=" + FACEBOOK_APPID + "&redirect_uri=" + URLEncoder.encode(FACEBOOK_REDIRECT, "utf-8") + "&state=" + fbstate);
+ response.setHeader("Location", "https://www.facebook.com/dialog/oauth?scope=publish_stream&client_id=" + FACEBOOK_APPID + "&redirect_uri=" + URLEncoder.encode(FACEBOOK_REDIRECT, CharEncoding.UTF_8) + "&state=" + fbstate);
return;
}
@@ -83,7 +84,7 @@ public class FacebookLogin {
response.addCookie(c);
}
- String token = Utils.fetchURL("https://graph.facebook.com/oauth/access_token?client_id=" + FACEBOOK_APPID + "&redirect_uri=" + URLEncoder.encode(FACEBOOK_REDIRECT, "utf-8") + "&client_secret=" + FACEBOOK_SECRET + "&code=" + URLEncoder.encode(code, "utf-8"));
+ String token = Utils.fetchURL("https://graph.facebook.com/oauth/access_token?client_id=" + FACEBOOK_APPID + "&redirect_uri=" + URLEncoder.encode(FACEBOOK_REDIRECT, CharEncoding.UTF_8) + "&client_secret=" + FACEBOOK_SECRET + "&code=" + URLEncoder.encode(code, CharEncoding.UTF_8));
if (token == null || token.isEmpty() || !token.startsWith("access_token=")) {
logger.error("FACEBOOK TOKEN ERROR: {}", token);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
diff --git a/juick-www/src/main/java/com/juick/www/Home.java b/juick-www/src/main/java/com/juick/www/Home.java
index 870c2d55..6bad083c 100644
--- a/juick-www/src/main/java/com/juick/www/Home.java
+++ b/juick-www/src/main/java/com/juick/www/Home.java
@@ -19,6 +19,7 @@ package com.juick.www;
import com.juick.server.AdsQueries;
import com.juick.server.MessagesQueries;
+import org.apache.commons.lang3.CharEncoding;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -148,7 +149,7 @@ public class Home {
nextpage += "&amp;show=" + paramShow;
}
if (paramSearch != null) {
- nextpage += "&amp;search=" + URLEncoder.encode(paramSearch, "UTF-8");
+ nextpage += "&amp;search=" + URLEncoder.encode(paramSearch, CharEncoding.UTF_8);
}
out.println("<p class=\"page\"><a href=\"" + nextpage + "\" rel=\"prev\">Читать дальше →</a></p>");
diff --git a/juick-www/src/main/java/com/juick/www/Main.java b/juick-www/src/main/java/com/juick/www/Main.java
index 27ecf3ec..077a3e32 100644
--- a/juick-www/src/main/java/com/juick/www/Main.java
+++ b/juick-www/src/main/java/com/juick/www/Main.java
@@ -22,6 +22,7 @@ import com.juick.server.UserQueries;
import com.mitchellbosecke.pebble.error.PebbleException;
import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.CharEncoding;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.jdbc.core.JdbcTemplate;
import rocks.xmpp.addr.Jid;
@@ -147,14 +148,14 @@ public class Main extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (request.getCharacterEncoding() == null) {
- request.setCharacterEncoding("UTF-8");
+ request.setCharacterEncoding(CharEncoding.UTF_8);
}
String uri = request.getRequestURI();
if (uri.equals("/")) {
String tag = request.getParameter("tag");
if (tag != null) {
- Utils.sendPermanentRedirect(response, "/tag/" + URLEncoder.encode(tag, "UTF-8"));
+ Utils.sendPermanentRedirect(response, "/tag/" + URLEncoder.encode(tag, CharEncoding.UTF_8));
} else {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
home.doGet(sql, sqlSearch, request, response, visitor);
@@ -323,7 +324,7 @@ public class Main extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (request.getCharacterEncoding() == null) {
- request.setCharacterEncoding("UTF-8");
+ request.setCharacterEncoding(CharEncoding.UTF_8);
}
String uri = request.getRequestURI();
diff --git a/juick-www/src/main/java/com/juick/www/NewMessage.java b/juick-www/src/main/java/com/juick/www/NewMessage.java
index 60ac08de..de6d8038 100644
--- a/juick-www/src/main/java/com/juick/www/NewMessage.java
+++ b/juick-www/src/main/java/com/juick/www/NewMessage.java
@@ -21,6 +21,7 @@ import com.juick.Tag;
import com.juick.server.*;
import com.juick.server.helpers.TagStats;
import net.coobird.thumbnailator.Thumbnails;
+import org.apache.commons.lang3.CharEncoding;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.Logger;
@@ -127,7 +128,7 @@ public class NewMessage {
String taglink = "";
try {
taglink = "<a onclick=\"return addTag('" + StringEscapeUtils.escapeHtml4(tags.get(i).getTag().getName()) + "')\" href=\"/" +
- visitor.getName() + "/?tag=" + URLEncoder.encode(tags.get(i).getTag().getName(), "utf-8") +
+ visitor.getName() + "/?tag=" + URLEncoder.encode(tags.get(i).getTag().getName(), CharEncoding.UTF_8) +
"\" title=\"" + tags.get(i).getUsageCount() + "\">" + StringEscapeUtils.escapeHtml4(tags.get(i).getTag().getName()) + "</a>";
} catch (UnsupportedEncodingException e) {
}
@@ -240,21 +241,21 @@ public class NewMessage {
tagscomma += jmsg.getTags().get(i);
}
- String url = URLEncoder.encode("http://juick.com/" + mid, "utf-8");
+ String url = URLEncoder.encode("http://juick.com/" + mid, CharEncoding.UTF_8);
String sharetwi = hashtags + " " + body;
if (sharetwi.length() > 115) {
sharetwi = sharetwi.substring(0, 114) + "…";
}
sharetwi += " http://juick.com/" + mid;
- String sharelj = URLEncoder.encode(body + "\n", "utf-8") + url;
+ String sharelj = URLEncoder.encode(body + "\n", CharEncoding.UTF_8) + url;
out.println("<section id=\"content\">");
out.println("<h1>Сообщение опубликовано</h1>");
out.println("<p>Поделитесь своим новым постом в социальных сетях:</p>");
if (CrosspostQueries.getTwitterTokens(sql, visitor.getUid()).isPresent()) {
- out.println("<p class=\"social\"><a href=\"https://twitter.com/intent/tweet?text=" + URLEncoder.encode(sharetwi, "utf-8") + "\" class=\"ico32-twi sharenew\">Отправить в Twitter</a></p>");
+ out.println("<p class=\"social\"><a href=\"https://twitter.com/intent/tweet?text=" + URLEncoder.encode(sharetwi, CharEncoding.UTF_8) + "\" class=\"ico32-twi sharenew\">Отправить в Twitter</a></p>");
}
- out.println("<p class=\"social\"><a href=\"http://www.livejournal.com/update.bml?subject=" + URLEncoder.encode(hashtags, "utf-8") + "&event=" + sharelj + "&prop_taglist=" + URLEncoder.encode(tagscomma, "utf-8") + "\" target=\"_blank\" class=\"ico32-lj sharenew\">Отправить в LiveJournal</a></p>");
+ out.println("<p class=\"social\"><a href=\"http://www.livejournal.com/update.bml?subject=" + URLEncoder.encode(hashtags, CharEncoding.UTF_8) + "&event=" + sharelj + "&prop_taglist=" + URLEncoder.encode(tagscomma, CharEncoding.UTF_8) + "\" target=\"_blank\" class=\"ico32-lj sharenew\">Отправить в LiveJournal</a></p>");
out.println("<p class=\"social\"><a href=\"https://vk.com/share.php?url=" + url + "\" class=\"ico32-vk sharenew\">Отправить в ВКонтакте</a></p>");
if (CrosspostQueries.getFacebookToken(sql, visitor.getUid()).isPresent()) {
out.println("<p class=\"social\"><a href=\"https://www.facebook.com/sharer/sharer.php?u=" + url + "\" class=\"ico32-fb sharenew\">Отправить в Facebook</a></p>");
diff --git a/juick-www/src/main/java/com/juick/www/PageTemplates.java b/juick-www/src/main/java/com/juick/www/PageTemplates.java
index 72d58e70..068da3c1 100644
--- a/juick-www/src/main/java/com/juick/www/PageTemplates.java
+++ b/juick-www/src/main/java/com/juick/www/PageTemplates.java
@@ -23,6 +23,7 @@ import com.juick.server.TagQueries;
import com.juick.server.UserQueries;
import com.juick.server.helpers.TagStats;
import com.juick.util.MessageUtils;
+import org.apache.commons.lang3.CharEncoding;
import org.apache.commons.lang3.StringEscapeUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -190,7 +191,7 @@ public class PageTemplates {
for (TagStats tag : tags) {
String tagName = StringEscapeUtils.escapeHtml4(tag.getTag().getName());
try {
- ret += "<a href=\"/tag/" + URLEncoder.encode(tag.getTag().getName(), "utf-8") + "\"";
+ ret += "<a href=\"/tag/" + URLEncoder.encode(tag.getTag().getName(), CharEncoding.UTF_8) + "\"";
if (tag.getUsageCount() < 2) {
ret += " rel=\"nofollow\"";
}
diff --git a/juick-www/src/main/java/com/juick/www/User.java b/juick-www/src/main/java/com/juick/www/User.java
index 088fb004..8a937565 100644
--- a/juick-www/src/main/java/com/juick/www/User.java
+++ b/juick-www/src/main/java/com/juick/www/User.java
@@ -21,6 +21,7 @@ import com.juick.server.MessagesQueries;
import com.juick.server.TagQueries;
import com.juick.server.UserQueries;
import com.juick.server.helpers.TagStats;
+import org.apache.commons.lang3.CharEncoding;
import org.apache.commons.lang3.StringEscapeUtils;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -59,7 +60,7 @@ public class User {
Errors.doGet404(sql, request, response);
return;
} else if (!paramTag.getName().equals(paramTagStr)) {
- String url = "/" + user.getName() + "/?tag=" + URLEncoder.encode(paramTag.getName(), "UTF-8");
+ String url = "/" + user.getName() + "/?tag=" + URLEncoder.encode(paramTag.getName(), CharEncoding.UTF_8);
Utils.sendPermanentRedirect(response, url);
return;
}
@@ -133,7 +134,7 @@ public class User {
if (paramTag != null) {
out.println("<p class=\"page\"><a href=\"/tag/" +
- URLEncoder.encode(paramTag.getName(), "UTF-8") + "\">← Все записи с тегом <b>" +
+ URLEncoder.encode(paramTag.getName(), CharEncoding.UTF_8) + "\">← Все записи с тегом <b>" +
StringEscapeUtils.escapeHtml4(paramTag.getName()) + "</b></a></p>");
}
@@ -145,10 +146,10 @@ public class User {
nextpage += "&amp;show=" + paramShow;
}
if (paramTag != null) {
- nextpage += "&amp;tag=" + URLEncoder.encode(paramTag.getName(), "UTF-8");
+ nextpage += "&amp;tag=" + URLEncoder.encode(paramTag.getName(), CharEncoding.UTF_8);
}
if (paramSearch != null) {
- nextpage += "&amp;search=" + URLEncoder.encode(paramSearch, "UTF-8");
+ nextpage += "&amp;search=" + URLEncoder.encode(paramSearch, CharEncoding.UTF_8);
}
out.println("<p class=\"page\"><a href=\"" + nextpage + "\" rel=\"prev\">Читать дальше →</a></p>");
}
@@ -332,7 +333,7 @@ public class User {
for (int i = 0; i < count; i++) {
String tag = StringEscapeUtils.escapeHtml4(tags.get(i).getTag().getName());
try {
- tag = "<a href=\"./?tag=" + URLEncoder.encode(tags.get(i).getTag().getName(), "UTF-8") + "\" title=\""
+ tag = "<a href=\"./?tag=" + URLEncoder.encode(tags.get(i).getTag().getName(), CharEncoding.UTF_8) + "\" title=\""
+ tags.get(i).getUsageCount() + "\" rel=\"nofollow\">" + tag + "</a>";
} catch (UnsupportedEncodingException e) {
}
diff --git a/juick-www/src/main/java/com/juick/www/VKontakteLogin.java b/juick-www/src/main/java/com/juick/www/VKontakteLogin.java
index 6b1d4571..92b22805 100644
--- a/juick-www/src/main/java/com/juick/www/VKontakteLogin.java
+++ b/juick-www/src/main/java/com/juick/www/VKontakteLogin.java
@@ -22,6 +22,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.juick.server.UserQueries;
import com.juick.www.vk.Token;
import com.juick.www.vk.UsersResponse;
+import org.apache.commons.lang3.CharEncoding;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.EmptyResultDataAccessException;
@@ -57,12 +58,12 @@ public class VKontakteLogin {
String code = request.getParameter("code");
if (code == null || code.equals("")) {
response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
- response.setHeader("Location", "https://oauth.vk.com/authorize?client_id=" + VK_APPID + "&redirect_uri=" + URLEncoder.encode(VK_REDIRECT, "utf-8") + "&scope=friends,wall,offline&response_type=code");
+ response.setHeader("Location", "https://oauth.vk.com/authorize?client_id=" + VK_APPID + "&redirect_uri=" + URLEncoder.encode(VK_REDIRECT, CharEncoding.UTF_8) + "&scope=friends,wall,offline&response_type=code");
return;
}
- String tokenjson = Utils.fetchURL("https://oauth.vk.com/access_token?client_id=" + VK_APPID + "&redirect_uri=" + URLEncoder.encode(VK_REDIRECT, "utf-8") + "&client_secret=" + VK_SECRET + "&code=" + URLEncoder.encode(code, "utf-8"));
+ String tokenjson = Utils.fetchURL("https://oauth.vk.com/access_token?client_id=" + VK_APPID + "&redirect_uri=" + URLEncoder.encode(VK_REDIRECT, CharEncoding.UTF_8) + "&client_secret=" + VK_SECRET + "&code=" + URLEncoder.encode(code, CharEncoding.UTF_8));
if (tokenjson == null || tokenjson.isEmpty()) {
logger.error("VK TOKEN EMPTY");
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
diff --git a/juick-xmpp-bot/src/main/java/com/juick/components/configuration/BotInitializer.java b/juick-xmpp-bot/src/main/java/com/juick/components/configuration/BotInitializer.java
index 1b8dd249..54dd6ff2 100644
--- a/juick-xmpp-bot/src/main/java/com/juick/components/configuration/BotInitializer.java
+++ b/juick-xmpp-bot/src/main/java/com/juick/components/configuration/BotInitializer.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,8 +29,7 @@ public class BotInitializer extends AbstractAnnotationConfigDispatcherServletIni
@Override
protected Filter[] getServletFilters() {
- CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
- characterEncodingFilter.setEncoding("UTF-8");
+ CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(CharEncoding.UTF_8);
return new Filter[]{characterEncodingFilter};
}
diff --git a/juick-xmpp-ft/src/main/java/com/juick/components/configuration/FileTransferInitializer.java b/juick-xmpp-ft/src/main/java/com/juick/components/configuration/FileTransferInitializer.java
index bf0e7257..7fac43d4 100644
--- a/juick-xmpp-ft/src/main/java/com/juick/components/configuration/FileTransferInitializer.java
+++ b/juick-xmpp-ft/src/main/java/com/juick/components/configuration/FileTransferInitializer.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,8 +29,7 @@ public class FileTransferInitializer extends AbstractAnnotationConfigDispatcherS
@Override
protected Filter[] getServletFilters() {
- CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
- characterEncodingFilter.setEncoding("UTF-8");
+ CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(CharEncoding.UTF_8);
return new Filter[]{characterEncodingFilter};
}
diff --git a/juick-xmpp/src/main/java/com/juick/components/configuration/XmppInitializer.java b/juick-xmpp/src/main/java/com/juick/components/configuration/XmppInitializer.java
index ee2ddceb..6453ef01 100644
--- a/juick-xmpp/src/main/java/com/juick/components/configuration/XmppInitializer.java
+++ b/juick-xmpp/src/main/java/com/juick/components/configuration/XmppInitializer.java
@@ -1,5 +1,6 @@
package com.juick.components.configuration;
+import org.apache.commons.lang3.CharEncoding;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
@@ -27,9 +28,7 @@ public class XmppInitializer extends AbstractAnnotationConfigDispatcherServletIn
@Override
protected Filter[] getServletFilters() {
- CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
- characterEncodingFilter.setEncoding("UTF-8");
-
+ CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(CharEncoding.UTF_8);
return new Filter[]{characterEncodingFilter};
}
diff --git a/src/test/java/com/juick/rss/LegacyRSS.java b/src/test/java/com/juick/rss/LegacyRSS.java
index ff84b784..1d6ef151 100644
--- a/src/test/java/com/juick/rss/LegacyRSS.java
+++ b/src/test/java/com/juick/rss/LegacyRSS.java
@@ -24,6 +24,7 @@ import com.juick.server.UserQueries;
import com.juick.util.DateFormattersHolder;
import com.juick.util.MessageUtils;
import org.apache.commons.dbcp2.BasicDataSource;
+import org.apache.commons.lang3.CharEncoding;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -52,7 +53,7 @@ public class LegacyRSS {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (request.getCharacterEncoding() == null) {
- request.setCharacterEncoding("UTF-8");
+ request.setCharacterEncoding(CharEncoding.UTF_8);
}
String uri = request.getRequestURI();
diff --git a/src/test/java/com/juick/tests/MessageTests.java b/src/test/java/com/juick/tests/MessageTests.java
index a0cfd444..6bc291e2 100644
--- a/src/test/java/com/juick/tests/MessageTests.java
+++ b/src/test/java/com/juick/tests/MessageTests.java
@@ -5,6 +5,7 @@ import static org.junit.Assert.assertEquals;
import com.juick.json.MessageSerializer;
import com.juick.util.DateFormattersHolder;
import com.juick.xmpp.extensions.JuickMessage;
+import org.apache.commons.lang3.CharEncoding;
import org.json.JSONObject;
import org.junit.Test;
@@ -40,7 +41,7 @@ public class MessageTests {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
- Document doc = db.parse(new ByteArrayInputStream(xmppMessage.toString().getBytes("UTF-8")));
+ Document doc = db.parse(new ByteArrayInputStream(xmppMessage.toString().getBytes(CharEncoding.UTF_8)));
Node juickNode = doc.getElementsByTagName("juick").item(0);
NamedNodeMap attrs = juickNode.getAttributes();
assertEquals("date should be in ts field", DateFormattersHolder.getMessageFormatterInstance().format(currentDate),