aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-12-16 15:41:14 +0300
committerGravatar Vitaly Takmazov2016-12-16 15:41:14 +0300
commit300a0439b2a6e26d9025247ef780c886616d4ae1 (patch)
treebcdb7613c2c5f37b870cbe18241894dba9428fae /juick-www/src/main
parent18a8595d2150edc92084c94b9dbb8f4309d3ed36 (diff)
CharEncoding.UTF_8
Diffstat (limited to 'juick-www/src/main')
-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
8 files changed, 31 insertions, 23 deletions
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);