From d69c492577eaebbd9fff7f7958528125fd6f5436 Mon Sep 17 00:00:00 2001 From: Kermina Awad Date: Fri, 5 Jun 2020 22:09:08 -0400 Subject: [PATCH] cleanup GitHub and Pastebin paste services --- .../utils/webpaste/GithubPasteService.java | 6 +++--- .../utils/webpaste/PastebinPasteService.java | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/webpaste/GithubPasteService.java b/src/main/java/com/onarandombox/MultiverseCore/utils/webpaste/GithubPasteService.java index 6d840969..fe7fafc4 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/webpaste/GithubPasteService.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/webpaste/GithubPasteService.java @@ -49,7 +49,9 @@ public class GithubPasteService implements PasteService { public URL getPostURL() { try { return new URL("https://api.github.com/gists"); - //return new URL("http://jsonplaceholder.typicode.com/posts"); + + // the following can be used for testing purposes + // return new URL("http://jsonplaceholder.typicode.com/posts"); } catch (MalformedURLException e) { return null; // should never hit here } @@ -68,8 +70,6 @@ public class GithubPasteService implements PasteService { rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line; - String pastieUrl = ""; - //Pattern pastiePattern = this.getURLMatchingPattern(); StringBuilder responseString = new StringBuilder(); while ((line = rd.readLine()) != null) { diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/webpaste/PastebinPasteService.java b/src/main/java/com/onarandombox/MultiverseCore/utils/webpaste/PastebinPasteService.java index 3f06f612..7aeba797 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/webpaste/PastebinPasteService.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/webpaste/PastebinPasteService.java @@ -40,12 +40,11 @@ public class PastebinPasteService implements PasteService { @Override public String encodeData(String data) { try { - String encData = URLEncoder.encode("api_dev_key", "UTF-8") + "=" + URLEncoder.encode("d61d68d31e8e0392b59b50b277411c71", "UTF-8"); - encData += "&" + URLEncoder.encode("api_option", "UTF-8") + "=" + URLEncoder.encode("paste", "UTF-8"); - encData += "&" + URLEncoder.encode("api_paste_code", "UTF-8") + "=" + URLEncoder.encode(data, "UTF-8"); - encData += "&" + URLEncoder.encode("api_paste_private", "UTF-8") + "=" + URLEncoder.encode(this.isPrivate ? "1" : "0", "UTF-8"); - encData += "&" + URLEncoder.encode("api_paste_format", "UTF-8") + "=" + URLEncoder.encode("yaml", "UTF-8"); - return encData; + return URLEncoder.encode("api_dev_key", "UTF-8") + "=" + URLEncoder.encode("d61d68d31e8e0392b59b50b277411c71", "UTF-8") + + "&" + URLEncoder.encode("api_option", "UTF-8") + "=" + URLEncoder.encode("paste", "UTF-8") + + "&" + URLEncoder.encode("api_paste_code", "UTF-8") + "=" + URLEncoder.encode(data, "UTF-8") + + "&" + URLEncoder.encode("api_paste_private", "UTF-8") + "=" + URLEncoder.encode(this.isPrivate ? "1" : "0", "UTF-8") + + "&" + URLEncoder.encode("api_paste_format", "UTF-8") + "=" + URLEncoder.encode("yaml", "UTF-8"); } catch (UnsupportedEncodingException e) { return ""; // should never hit here }