From 300a0439b2a6e26d9025247ef780c886616d4ae1 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Fri, 16 Dec 2016 15:41:14 +0300
Subject: CharEncoding.UTF_8
---
.../main/java/com/juick/api/configuration/ApiInitializer.java | 4 ++--
.../src/main/java/com/juick/components/Crosspost.java | 9 +++++----
.../juick/components/configuration/CrosspostInitializer.java | 5 ++---
.../components/configuration/NotificationsInitializer.java | 4 ++--
.../main/java/com/juick/rss/configuration/RssInitializer.java | 4 ++--
.../java/com/juick/www/configuration/WebAppConfiguration.java | 3 ++-
.../main/java/com/juick/www/configuration/WwwInitializer.java | 3 ++-
.../com/juick/www/configuration/WwwServletConfiguration.java | 5 +++--
.../main/java/com/juick/www/controllers/IndexController.java | 3 ++-
.../main/java/com/juick/www/controllers/TagController.java | 7 ++++---
juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java | 3 ++-
.../java/com/juick/ws/configuration/WebsocketInitializer.java | 3 ++-
juick-www/src/main/java/com/juick/www/Discover.java | 9 +++++----
juick-www/src/main/java/com/juick/www/FacebookLogin.java | 5 +++--
juick-www/src/main/java/com/juick/www/Home.java | 3 ++-
juick-www/src/main/java/com/juick/www/Main.java | 7 ++++---
juick-www/src/main/java/com/juick/www/NewMessage.java | 11 ++++++-----
juick-www/src/main/java/com/juick/www/PageTemplates.java | 3 ++-
juick-www/src/main/java/com/juick/www/User.java | 11 ++++++-----
juick-www/src/main/java/com/juick/www/VKontakteLogin.java | 5 +++--
.../com/juick/components/configuration/BotInitializer.java | 4 ++--
.../components/configuration/FileTransferInitializer.java | 4 ++--
.../com/juick/components/configuration/XmppInitializer.java | 5 ++---
src/test/java/com/juick/rss/LegacyRSS.java | 3 ++-
src/test/java/com/juick/tests/MessageTests.java | 3 ++-
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 Поделитесь своим новым постом в социальных сетях:Сообщение опубликовано
");
out.println("