Escape backslash (\) in SQL Strings as they can break queries unescaped.
This commit is contained in:
parent
e246589cdf
commit
a9e1cf3f51
1 changed files with 6 additions and 3 deletions
|
@ -1580,7 +1580,7 @@ public final class DbMapping {
|
|||
String str = value == null ? null : value.toString();
|
||||
if (str == null) {
|
||||
return null;
|
||||
} else if (str.indexOf("'") < 0) {
|
||||
} else if (str.indexOf('\'') < 0 && str.indexOf('\\') < 0) {
|
||||
return str;
|
||||
}
|
||||
|
||||
|
@ -1591,10 +1591,13 @@ public final class DbMapping {
|
|||
char c = str.charAt(i);
|
||||
|
||||
if (c == '\'') {
|
||||
sbuf.append('\'');
|
||||
}
|
||||
sbuf.append("\\'");
|
||||
} else if (c == '\\') {
|
||||
sbuf.append("\\\\");
|
||||
} else {
|
||||
sbuf.append(c);
|
||||
}
|
||||
}
|
||||
return sbuf.toString();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue