Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复反斜杠\识别的bug #101

Open
wants to merge 1 commit into
base: branch_version_3.2.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/com/ql/util/express/parse/WordSplit.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static Word[] parse(String[] splitWord,String str) throws Exception{
if (c=='"' || c=='\''){//字符串处理
int index = str.indexOf(c,i + 1);
//处理字符串中的”问题
while(index >0 && str.charAt(index - 1) =='\\'){
while(index >0 && str.charAt(index - 1) =='\\' && str.charAt(index - 2) !='\\'){
index = str.indexOf(c,index + 1);
}
if (index < 0)
Expand Down
19 changes: 19 additions & 0 deletions src/test/java/com/ql/util/express/bugfix/BackSlashTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.ql.util.express.bugfix;

import com.ql.util.express.DefaultContext;
import com.ql.util.express.ExpressRunner;
import com.ql.util.express.IExpressContext;
import org.junit.Test;

//脚本中包含 反斜杠 测试
public class BackSlashTest {

@Test
public void test() throws Exception {
ExpressRunner runner = new ExpressRunner();
String exp = "a=\"\\\\\";";
IExpressContext<String, Object> context = new DefaultContext<String, Object>();
Object result = runner.execute(exp,context,null,false,true);
System.out.println(result);
}
}