Skip to content

Commit

Permalink
fixes mybatis#194 Incorrect parse result when a variable precedes a s…
Browse files Browse the repository at this point in the history
…kipped variable.
  • Loading branch information
harawata committed May 9, 2014
1 parent 1d33035 commit 9476328
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public String parse(String text) {
while (start > -1) {
if (start > 0 && src[start - 1] == '\\') {
// the variable is escaped. remove the backslash.
builder.append(src, offset, start - 1).append(openToken);
builder.append(src, offset, start - offset - 1).append(openToken);
offset = start + openToken.length();
} else {
int end = text.indexOf(closeToken, start);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public void shallNotInterpolateSkippedVaiables() {

assertEquals("${skipped} variable", parser.parse("\\${skipped} variable"));
assertEquals("This is a ${skipped} variable", parser.parse("This is a \\${skipped} variable"));
assertEquals("null ${skipped} variable", parser.parse("${skipped} \\${skipped} variable"));
assertEquals("The null is ${skipped} variable", parser.parse("The ${skipped} is \\${skipped} variable"));
}

@Test(timeout = 1000)
Expand Down

0 comments on commit 9476328

Please sign in to comment.