Skip to content

Commit

Permalink
Issue 114: Blank strings in brackets being casted to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
chbloemer committed Nov 11, 2015
1 parent c3ce70d commit d0cd603
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/org/apache/commons/jexl2/JadeJexlArithmetic.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.Collection;

public class JadeJexlArithmetic extends JexlArithmetic {

public JadeJexlArithmetic(boolean lenient) {
super(lenient);
}
Expand Down Expand Up @@ -34,4 +35,14 @@ public boolean toBoolean(Object val) {

return true;
}

@Override
public Object add(Object left, Object right) {
if (left instanceof String || right instanceof String) {
return left.toString() + right.toString();
}
else {
return super.add(left, right);
}
}
}
1 change: 1 addition & 0 deletions src/test/resources/issues/114.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<input value=""/>
2 changes: 2 additions & 0 deletions src/test/resources/issues/114.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-var blank = ""
input(value="#{blank}")

0 comments on commit d0cd603

Please sign in to comment.