提交 3053b2dd authored 作者: Thomas Mueller's avatar Thomas Mueller

SQL statements with a non-breaking space were considered invalid.

上级 94e4097b
...@@ -60,7 +60,7 @@ class RuleElement implements Rule { ...@@ -60,7 +60,7 @@ class RuleElement implements Rule {
String up = sentence.getQueryUpper().trim(); String up = sentence.getQueryUpper().trim();
if (up.startsWith(name)) { if (up.startsWith(name)) {
query = query.substring(name.length()); query = query.substring(name.length());
while (!"_".equals(name) && query.length() > 0 && Character.isWhitespace(query.charAt(0))) { while (!"_".equals(name) && query.length() > 0 && Character.isSpaceChar(query.charAt(0))) {
query = query.substring(1); query = query.substring(1);
} }
sentence.setQuery(query); sentence.setQuery(query);
......
...@@ -108,7 +108,7 @@ public class RuleFixed implements Rule { ...@@ -108,7 +108,7 @@ public class RuleFixed implements Rule {
} }
break; break;
case ANY_WORD: case ANY_WORD:
while (s.length() > 0 && !Character.isWhitespace(s.charAt(0))) { while (s.length() > 0 && !Character.isSpaceChar(s.charAt(0))) {
s = s.substring(1); s = s.substring(1);
} }
if (s.length() == 0) { if (s.length() == 0) {
...@@ -182,7 +182,7 @@ public class RuleFixed implements Rule { ...@@ -182,7 +182,7 @@ public class RuleFixed implements Rule {
throw new AssertionError("type="+type); throw new AssertionError("type="+type);
} }
if (!s.equals(query)) { if (!s.equals(query)) {
while (s.length() > 0 && Character.isWhitespace(s.charAt(0))) { while (s.length() > 0 && Character.isSpaceChar(s.charAt(0))) {
s = s.substring(1); s = s.substring(1);
} }
sentence.setQuery(s); sentence.setQuery(s);
......
...@@ -176,7 +176,7 @@ public class DbContextRule implements Rule { ...@@ -176,7 +176,7 @@ public class DbContextRule implements Rule {
throw DbException.throwInternalError("type=" + type); throw DbException.throwInternalError("type=" + type);
} }
if (!s.equals(query)) { if (!s.equals(query)) {
while (s.length() > 0 && Character.isWhitespace(s.charAt(0))) { while (s.length() > 0 && Character.isSpaceChar(s.charAt(0))) {
s = s.substring(1); s = s.substring(1);
} }
sentence.setQuery(s); sentence.setQuery(s);
......
...@@ -287,7 +287,7 @@ public class WebApp { ...@@ -287,7 +287,7 @@ public class WebApp {
String space = ""; String space = "";
if (sql.length() > 0) { if (sql.length() > 0) {
char last = sql.charAt(sql.length() - 1); char last = sql.charAt(sql.length() - 1);
if (!Character.isWhitespace(last) && (last != '.' && last >= ' ' && last != '\'' && last != '"')) { if (!Character.isSpaceChar(last) && (last != '.' && last >= ' ' && last != '\'' && last != '"')) {
space = " "; space = " ";
} }
} }
......
...@@ -195,7 +195,7 @@ public class PrepareTranslation { ...@@ -195,7 +195,7 @@ public class PrepareTranslation {
private static String getSpace(String s, boolean start) { private static String getSpace(String s, boolean start) {
if (start) { if (start) {
for (int i = 0; i < s.length(); i++) { for (int i = 0; i < s.length(); i++) {
if (!Character.isWhitespace(s.charAt(i))) { if (!Character.isSpaceChar(s.charAt(i))) {
if (i == 0) { if (i == 0) {
return ""; return "";
} }
...@@ -205,7 +205,7 @@ public class PrepareTranslation { ...@@ -205,7 +205,7 @@ public class PrepareTranslation {
return s; return s;
} }
for (int i = s.length() - 1; i >= 0; i--) { for (int i = s.length() - 1; i >= 0; i--) {
if (!Character.isWhitespace(s.charAt(i))) { if (!Character.isSpaceChar(s.charAt(i))) {
if (i == s.length() - 1) { if (i == s.length() - 1) {
return ""; return "";
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论