Skip to content

Commit

Permalink
ISSUE-291: fix substring issue with empty dot
Browse files Browse the repository at this point in the history
  • Loading branch information
spullara committed Aug 25, 2023
1 parent 3433d0c commit 304f71a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.util.Optional;


abstract class AbstractObjectHandler implements ObjectHandler {
public abstract class AbstractObjectHandler implements ObjectHandler {

protected static final Object NOT_FOUND = new Object();

Expand All @@ -27,6 +27,7 @@ public Object coerce(Object object) {
return object;
}


@Override
public Writer falsey(Iteration iteration, Writer writer, Object object, List<Object> scopes) {
if (object != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ protected AccessibleObject findMember(Class sClass, String name) {
}

private AccessibleObject findMemberOnClass(Class sClass, String name) {
if (name.isEmpty()) return null;
AccessibleObject ao;
try {
ao = getMethod(sClass, name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,16 @@ public void testInvalidDelimiters() {
}
}

public void testEmptyDot() {
MustacheFactory mf = createMustacheFactory();
StringWriter sw = new StringWriter();
Mustache mustache = mf.compile(new StringReader("{{No.}}"), "template");
Map<String, String> scope = new HashMap<>();
scope.put("No", "1");
mustache.execute(sw, scope);
System.out.println(sw);
}

public void testTemplateFunction() throws IOException {
MustacheFactory mf = createMustacheFactory();
Mustache m = mf.compile(new StringReader("{{#i}}{{{test}}}{{f}}{{/i}}" +
Expand Down

0 comments on commit 304f71a

Please sign in to comment.