From dc9eb185970ea1d664aacf856042906cf14286c0 Mon Sep 17 00:00:00 2001
From: Matteo Morena <8678043+xmamo@users.noreply.github.com>
Date: Thu, 25 Feb 2016 12:57:51 +0100
Subject: [PATCH] Fix #10
---
pom.xml | 2 +-
.../vanillaVotifier/impl/JsonConfig.java | 2 +-
.../impl/PropertiesLanguagePack.java | 164 +++++++++---------
3 files changed, 84 insertions(+), 84 deletions(-)
diff --git a/pom.xml b/pom.xml
index 476f22d..97b0bb9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,7 +19,7 @@ this program. If not, see .
4.0.0
co.virtualdragon
VanillaVotifier
- 3.3
+ 3.3.1
VanillaVotifier
jar
diff --git a/src/main/java/co/virtualdragon/vanillaVotifier/impl/JsonConfig.java b/src/main/java/co/virtualdragon/vanillaVotifier/impl/JsonConfig.java
index 1bb850a..9cdaca2 100644
--- a/src/main/java/co/virtualdragon/vanillaVotifier/impl/JsonConfig.java
+++ b/src/main/java/co/virtualdragon/vanillaVotifier/impl/JsonConfig.java
@@ -74,7 +74,7 @@ public synchronized void load() throws IOException, InvalidKeySpecException {
stringBuilder.append((char) i);
}
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(configFile));
- for (char c : stringBuilder.toString().replaceAll("\\R", System.lineSeparator()).toCharArray()) {
+ for (char c : stringBuilder.toString().replaceAll("\\u000D\\u000A|[\\u000A\\u000B\\u000C\\u000D\\u0085\\u2028\\u2029]", System.lineSeparator()).toCharArray()) {
out.write((int) c);
}
out.flush();
diff --git a/src/main/java/co/virtualdragon/vanillaVotifier/impl/PropertiesLanguagePack.java b/src/main/java/co/virtualdragon/vanillaVotifier/impl/PropertiesLanguagePack.java
index 811c438..0f9d238 100644
--- a/src/main/java/co/virtualdragon/vanillaVotifier/impl/PropertiesLanguagePack.java
+++ b/src/main/java/co/virtualdragon/vanillaVotifier/impl/PropertiesLanguagePack.java
@@ -1,82 +1,82 @@
-/*
- * Copyright (C) 2015 VirtualDragon
- *
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program. If not, see .
- */
-package co.virtualdragon.vanillaVotifier.impl;
-
-import co.virtualdragon.vanillaVotifier.LanguagePack;
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map.Entry;
-import java.util.ResourceBundle;
-import org.apache.commons.lang3.exception.ExceptionUtils;
-import org.apache.commons.lang3.text.StrSubstitutor;
-
-public class PropertiesLanguagePack implements LanguagePack {
-
- private final ResourceBundle bundle;
-
- public PropertiesLanguagePack(String languagePackName) {
- bundle = ResourceBundle.getBundle(languagePackName);
- }
-
- @Override
- public String getString(String key) {
- return getString(key, new Entry[]{});
- }
-
- @Override
- public String getString(String key, Entry... substitutions) {
- String string = null;
- if (bundle.containsKey(key)) {
- string = bundle.getString(key).replaceAll("\\R", System.lineSeparator());
- } else if (bundle.containsKey(key + "-location")) {
- String resource = getString(key + "-location");
- if (resource == null) {
- return null;
- }
- if (!resource.startsWith("/")) {
- resource = "/co/virtualdragon/vanillaVotifier/impl/lang/" + resource;
- }
- BufferedInputStream in;
- in = new BufferedInputStream(PropertiesLanguagePack.class.getResourceAsStream(resource));
- StringBuilder stringBuilder = new StringBuilder();
- int i;
- try {
- while ((i = in.read()) != -1) {
- stringBuilder.append((char) i);
- }
- in.close();
- } catch (IOException e) {
- // Can't happen.
- }
- string = stringBuilder.toString().replaceAll("\\R", System.lineSeparator());
- }
- if (substitutions == null || string == null) {
- return string;
- } else {
- HashMap substitutionsMap = new HashMap();
- for (Entry substitution : substitutions) {
- if (!(substitution.getValue() instanceof Throwable)) {
- substitutionsMap.put(substitution.getKey(), substitution.getValue());
- } else {
- substitutionsMap.put(substitution.getKey(), ExceptionUtils.getStackTrace((Throwable) substitution.getValue()));
- }
- }
- return new StrSubstitutor(substitutionsMap).replace(string);
- }
- }
-}
+/*
+ * Copyright (C) 2015 VirtualDragon
+ *
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ */
+package co.virtualdragon.vanillaVotifier.impl;
+
+import co.virtualdragon.vanillaVotifier.LanguagePack;
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map.Entry;
+import java.util.ResourceBundle;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.apache.commons.lang3.text.StrSubstitutor;
+
+public class PropertiesLanguagePack implements LanguagePack {
+
+ private final ResourceBundle bundle;
+
+ public PropertiesLanguagePack(String languagePackName) {
+ bundle = ResourceBundle.getBundle(languagePackName);
+ }
+
+ @Override
+ public String getString(String key) {
+ return getString(key, new Entry[]{});
+ }
+
+ @Override
+ public String getString(String key, Entry... substitutions) {
+ String string = null;
+ if (bundle.containsKey(key)) {
+ string = bundle.getString(key).replaceAll("\\u000D\\u000A|[\\u000A\\u000B\\u000C\\u000D\\u0085\\u2028\\u2029]", System.lineSeparator());
+ } else if (bundle.containsKey(key + "-location")) {
+ String resource = getString(key + "-location");
+ if (resource == null) {
+ return null;
+ }
+ if (!resource.startsWith("/")) {
+ resource = "/co/virtualdragon/vanillaVotifier/impl/lang/" + resource;
+ }
+ BufferedInputStream in;
+ in = new BufferedInputStream(PropertiesLanguagePack.class.getResourceAsStream(resource));
+ StringBuilder stringBuilder = new StringBuilder();
+ int i;
+ try {
+ while ((i = in.read()) != -1) {
+ stringBuilder.append((char) i);
+ }
+ in.close();
+ } catch (IOException e) {
+ // Can't happen.
+ }
+ string = stringBuilder.toString().replaceAll("\\u000D\\u000A|[\\u000A\\u000B\\u000C\\u000D\\u0085\\u2028\\u2029]", System.lineSeparator());
+ }
+ if (substitutions == null || string == null) {
+ return string;
+ } else {
+ HashMap substitutionsMap = new HashMap();
+ for (Entry substitution : substitutions) {
+ if (!(substitution.getValue() instanceof Throwable)) {
+ substitutionsMap.put(substitution.getKey(), substitution.getValue());
+ } else {
+ substitutionsMap.put(substitution.getKey(), ExceptionUtils.getStackTrace((Throwable) substitution.getValue()));
+ }
+ }
+ return new StrSubstitutor(substitutionsMap).replace(string);
+ }
+ }
+}