3356a_20171011a.patch
src/com/goldencode/p2j/report/server/DatabaseService.java 2017-10-12 02:37:04 +0000 | ||
---|---|---|
6 | 6 |
** |
7 | 7 |
** -#- -I- --Date-- --------------------------------Description---------------------------------- |
8 | 8 |
** 001 ECF 20170428 Created first version. |
9 |
** 002 ECF 20171011 Escape single backslash character in LIKE phrase r-value. |
|
9 | 10 |
*/ |
10 | 11 |
/* |
11 | 12 |
** This program is free software: you can redistribute it and/or modify |
... | ... | |
169 | 170 |
/** |
170 | 171 |
* Escape all percent and underscore symbols in the text that will be used as the r-value |
171 | 172 |
* of a SQL LIKE expression, since these characters have special meaning to the LIKE |
172 |
* processing. Backslash ({@code \}) is used as the escape character. |
|
173 |
* processing. Backslash ({@code \}) is used as the escape character. Also escape single |
|
174 |
* backslash characters. |
|
173 | 175 |
* |
174 | 176 |
* @param text |
175 | 177 |
* R-value text. |
... | ... | |
178 | 180 |
*/ |
179 | 181 |
String escapeLikeRValue(String text) |
180 | 182 |
{ |
181 |
return text.replaceAll("%", "\\%").replaceAll("_", "\\_"); |
|
183 |
return text.replaceAll("\\\\", "\\\\\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_");
|
|
182 | 184 |
} |
183 | 185 |
|
184 | 186 |
/** |