Skip to content

Commit

Permalink
Fix percent sign escaping with strings with no variables (#600)
Browse files Browse the repository at this point in the history
  • Loading branch information
bensku committed Jun 2, 2017
1 parent 85ccf45 commit 9838668
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
groupid=ch.njol
name=skript
version=2.2-dev28b
version=2.2-dev28c
22 changes: 17 additions & 5 deletions src/main/java/ch/njol/skript/lang/VariableString.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,28 @@ private final static class ExpressionInfo {
private final String simpleUnformatted;
private final StringMode mode;

/**
* Creates a new VariableString which does not contain variables.
* @param s Content for string.
*/
private VariableString(final String s) {
isSimple = true;
simpleUnformatted = s;
simple = Utils.replaceChatStyles(s);
simpleUnformatted = s.replace("%%", "%"); // This doesn't contain variables, so this wasn't done in newInstance!
assert simpleUnformatted != null;
simple = Utils.replaceChatStyles(simpleUnformatted);

orig = simple;
string = null;
assert simple != null;
mode = StringMode.MESSAGE;
}

/**
* Creates a new VariableString which contains variables.
* @param orig Original string (unparsed).
* @param string Objects, some of them are variables.
* @param mode String mode.
*/
private VariableString(final String orig, final Object[] string, final StringMode mode) {
this.orig = orig;
this.string = new Object[string.length];
Expand Down Expand Up @@ -172,11 +183,12 @@ public final static String unquote(final String s, final boolean surroundingQuot
}

/**
* Prints errors
* Creates an instance of VariableString by parsing given string.
* Prints errors and returns null if it is somehow invalid.
*
* @param orig unquoted string
* @param orig Unquoted string to parse.
* @param mode
* @return A new VariableString instance
* @return A new VariableString instance.
*/
@Nullable
public static VariableString newInstance(final String orig, final StringMode mode) {
Expand Down

0 comments on commit 9838668

Please sign in to comment.