Mercurial > hg > Database > jungle-network
changeset 173:e30880a72909
change servlet encode utf-8
author | tatsuki |
---|---|
date | Wed, 30 Jul 2014 17:46:58 +0900 |
parents | d483caeabffc |
children | 066f58e93a14 |
files | src/main/java/app/bbs/NetworkJungleBulletinBoard.java src/main/java/app/bbs/ShowMessageWithTimeStampServlet.java src/main/java/app/bbs/thinks/CreateNode.java src/main/java/app/bbs/thinks/EditAttributeServlet.java src/main/java/app/bbs/thinks/EditNodeName.java src/main/java/app/bbs/thinks/ShowMatrix.java src/main/java/app/bbs/thinks/createAttributeMatrix.java src/main/java/app/bbs/thinks/deleteAttributeServlet.java src/main/java/app/bbs/thinks/deleteNodeServlet.java |
diffstat | 9 files changed, 62 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/app/bbs/NetworkJungleBulletinBoard.java Wed Jul 30 17:17:08 2014 +0900 +++ b/src/main/java/app/bbs/NetworkJungleBulletinBoard.java Wed Jul 30 17:46:58 2014 +0900 @@ -126,6 +126,7 @@ IterableConverter.Converter<String, Node> converter = new IterableConverter.Converter<String, Node>() { public String conv(Node _b) { ByteBuffer e = _b.getAttributes().get("name"); + System.out.println(new String(e.array())); return new String(e.array()); } }; @@ -375,7 +376,7 @@ } while (either.isA()); } - public void editAttribute(String boardName, String _path, String id, String _message) { + public void editAttribute(String boardName, String _path, final String id, final String _message) { requestCounter.incrementAndGet(); final long timestamp = System.currentTimeMillis(); final ByteBuffer tBuffer = ByteBuffer.allocate(16);
--- a/src/main/java/app/bbs/ShowMessageWithTimeStampServlet.java Wed Jul 30 17:17:08 2014 +0900 +++ b/src/main/java/app/bbs/ShowMessageWithTimeStampServlet.java Wed Jul 30 17:46:58 2014 +0900 @@ -6,6 +6,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.lang.StringEscapeUtils; import org.eclipse.jetty.util.thread.ThreadPool; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.BoardMessage; @@ -32,8 +33,9 @@ } public void doGet(HttpServletRequest _req, HttpServletResponse _res) { - final String bname = _req.getParameter(PARAM_BOARD_NAME); + final String bname = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_NAME)); try { + _res.setCharacterEncoding("UTF-8"); printBoard(bname, _res.getWriter()); } catch (Exception _e) { _res.setStatus(500);
--- a/src/main/java/app/bbs/thinks/CreateNode.java Wed Jul 30 17:17:08 2014 +0900 +++ b/src/main/java/app/bbs/thinks/CreateNode.java Wed Jul 30 17:46:58 2014 +0900 @@ -6,6 +6,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.lang.StringEscapeUtils; + import app.bbs.NetworkBulletinBoard; public class CreateNode extends HttpServlet { @@ -22,11 +24,11 @@ } public void doPost(HttpServletRequest _req, HttpServletResponse _res) { - String boardName = _req.getParameter(PARAM_BOARD_NAME); - String author = _req.getParameter(PARAM_BOARD_AUTHOR);//not use - String nodeName = _req.getParameter(PARAM_NODE_NAME); - String key = _req.getParameter(PARAM_BOARD_EDITKEY);//not use - String nodeNum = _req.getParameter(PARAM_BOARD_PATH); + String boardName = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_NAME)); + String author = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_AUTHOR));//not use + String nodeName = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_NODE_NAME)); + String key = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_EDITKEY));//not use + String nodeNum = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_PATH)); try { bbs.createFolder(boardName, author, nodeName, key, nodeNum);
--- a/src/main/java/app/bbs/thinks/EditAttributeServlet.java Wed Jul 30 17:17:08 2014 +0900 +++ b/src/main/java/app/bbs/thinks/EditAttributeServlet.java Wed Jul 30 17:46:58 2014 +0900 @@ -6,6 +6,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.lang.StringEscapeUtils; + import app.bbs.NetworkBulletinBoard; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.BulletinBoard; @@ -26,12 +28,13 @@ public void doGet(HttpServletRequest _req,HttpServletResponse _res) { - String bname = _req.getParameter(PARAM_BOARD_NAME); - String path = _req.getParameter(PARAM_NODE_ID); - String id = _req.getParameter(PARAM_NODE_ID); + String bname = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_NAME)); + String path = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_NODE_ID)); + String id = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_NODE_ID)); try{ + _res.setCharacterEncoding("UTF-8"); PrintWriter pw = _res.getWriter(); pw.write("<html><body><h1>edit message</h1>"); pw.write("<form method='POST'\n"); @@ -49,10 +52,10 @@ public void doPost(HttpServletRequest _req,HttpServletResponse _res) { - String boardName = _req.getParameter(PARAM_BOARD_NAME); - String msg = _req.getParameter(PARAM_BOARD_MESSAGE); - String path = _req.getParameter("path"); - String id = _req.getParameter("id"); + String boardName = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_NAME)); + String msg = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_MESSAGE)); + String path = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_NODE_ID)); + String id = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_NODE_ID)); try{ bbs.editAttribute(boardName, path,id, msg);
--- a/src/main/java/app/bbs/thinks/EditNodeName.java Wed Jul 30 17:17:08 2014 +0900 +++ b/src/main/java/app/bbs/thinks/EditNodeName.java Wed Jul 30 17:46:58 2014 +0900 @@ -6,6 +6,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.lang.StringEscapeUtils; + import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.BulletinBoard; public class EditNodeName extends HttpServlet @@ -26,11 +28,12 @@ public void doGet(HttpServletRequest _req,HttpServletResponse _res) { - String bname = _req.getParameter(PARAM_BOARD_NAME); - String path = _req.getParameter(PARAM_NODE_PATH); + String bname = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_NAME)); + String path = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_NODE_PATH)); try{ + _res.setCharacterEncoding("UTF-8"); PrintWriter pw = _res.getWriter(); pw.write("<html><body><h1>edit message</h1>"); pw.write("<form method='POST'\n"); @@ -48,11 +51,11 @@ public void doPost(HttpServletRequest _req,HttpServletResponse _res) { - String boardName = _req.getParameter(PARAM_BOARD_NAME); - String author = _req.getParameter(PARAM_BOARD_AUTHOR); - String msg = _req.getParameter(PARAM_BOARD_MESSAGE); - String key = _req.getParameter(PARAM_BOARD_EDITKEY); - String path = _req.getParameter(PARAM_NODE_PATH); + String boardName = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_NAME)); + String author = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_AUTHOR)); + String msg = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_MESSAGE)); + String key = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_EDITKEY)); + String path = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_NODE_PATH)); try{ bbs.editMessage(boardName, path, author, msg, key);
--- a/src/main/java/app/bbs/thinks/ShowMatrix.java Wed Jul 30 17:17:08 2014 +0900 +++ b/src/main/java/app/bbs/thinks/ShowMatrix.java Wed Jul 30 17:46:58 2014 +0900 @@ -6,6 +6,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.lang.StringEscapeUtils; import org.eclipse.jetty.util.thread.ThreadPool; import app.bbs.NetworkBulletinBoard; @@ -41,10 +42,11 @@ } public void doGet(HttpServletRequest _req, HttpServletResponse _res) { - final String bname = _req.getParameter(PARAM_BOARD_NAME); - String path = _req.getParameter(PARAM_NODE_PATH); - String nodeName = _req.getParameter(PARAM_NODE_NAME); + final String bname = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_NAME)); + String path = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_NODE_PATH)); + String nodeName = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_NODE_NAME)); try { + _res.setCharacterEncoding("UTF-8"); printBoard(bname, path, nodeName, _res.getWriter()); } catch (Exception _e) { _res.setStatus(500);
--- a/src/main/java/app/bbs/thinks/createAttributeMatrix.java Wed Jul 30 17:17:08 2014 +0900 +++ b/src/main/java/app/bbs/thinks/createAttributeMatrix.java Wed Jul 30 17:46:58 2014 +0900 @@ -6,6 +6,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.lang.StringEscapeUtils; + import app.bbs.NetworkBulletinBoard; public class createAttributeMatrix extends HttpServlet @@ -28,11 +30,11 @@ public void doPost(HttpServletRequest _req,HttpServletResponse _res) { - String boardName = _req.getParameter(PARAM_BOARD_NAME); - String author = _req.getParameter(PARAM_BOARD_AUTHOR);//not use - String msg = _req.getParameter(PARAM_BOARD_MESSAGE); - String key = _req.getParameter(PARAM_BOARD_EDITKEY); // not use - String uuid = _req.getParameter(PARAM_NODE_PATH); + String boardName = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_NAME)); + String author = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_AUTHOR));//not use + String msg = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_MESSAGE)); + String key = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_EDITKEY)); // not use + String uuid = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_NODE_PATH)); try{ bbs.createAttribute(boardName, uuid, author, msg, key); PrintWriter pw = _res.getWriter();
--- a/src/main/java/app/bbs/thinks/deleteAttributeServlet.java Wed Jul 30 17:17:08 2014 +0900 +++ b/src/main/java/app/bbs/thinks/deleteAttributeServlet.java Wed Jul 30 17:46:58 2014 +0900 @@ -6,6 +6,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.lang.StringEscapeUtils; + import app.bbs.NetworkBulletinBoard; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.BulletinBoard; @@ -26,12 +28,13 @@ public void doGet(HttpServletRequest _req,HttpServletResponse _res) { - String bname = _req.getParameter(PARAM_BOARD_NAME); - String path = _req.getParameter(PARAM_NODE_ID); - String id = _req.getParameter(PARAM_NODE_ID); + String bname = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_NAME)); + String path = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_NODE_ID)); + String id = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_NODE_ID)); try{ + _res.setCharacterEncoding("UTF-8"); PrintWriter pw = _res.getWriter(); pw.write("<html><body><h1>delete Attribute ?</h1>"); pw.write("<form method='POST'\n"); @@ -48,9 +51,9 @@ public void doPost(HttpServletRequest _req,HttpServletResponse _res) { - String boardName = _req.getParameter(PARAM_BOARD_NAME); - String path = _req.getParameter("path"); - String id = _req.getParameter("id"); + String boardName = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_NAME)); + String path = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_NODE_ID)); + String id = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_NODE_ID)); try{ bbs.deleteAttribute(boardName, path,id);
--- a/src/main/java/app/bbs/thinks/deleteNodeServlet.java Wed Jul 30 17:17:08 2014 +0900 +++ b/src/main/java/app/bbs/thinks/deleteNodeServlet.java Wed Jul 30 17:46:58 2014 +0900 @@ -5,6 +5,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.lang.StringEscapeUtils; + import app.bbs.NetworkBulletinBoard; public class deleteNodeServlet extends HttpServlet @@ -23,11 +25,12 @@ public void doGet(HttpServletRequest _req,HttpServletResponse _res) { - String bname = _req.getParameter(PARAM_BOARD_NAME); - String path = _req.getParameter(PARAM_BOARD_PATH ); - String id = _req.getParameter(PARAM_NODE_ID); + String bname = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_NAME)); + String path = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_PATH )); + String id = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_NODE_ID)); try{ + _res.setCharacterEncoding("UTF-8"); PrintWriter pw = _res.getWriter(); pw.write("<html><body><h1>delete message ?</h1>"); pw.write("<form method='POST'\n"); @@ -44,9 +47,9 @@ public void doPost(HttpServletRequest _req,HttpServletResponse _res) { - String boardName = _req.getParameter(PARAM_BOARD_NAME); - String path = _req.getParameter(PARAM_BOARD_PATH); - String id = _req.getParameter(PARAM_NODE_ID); + String boardName = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_NAME)); + String path = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_PATH)); + String id = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_NODE_ID)); try{ bbs.deleteNode(boardName, path, id); PrintWriter pw = _res.getWriter();