mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Update the definition of "special characters" for the SQLTester and correct the code to match it.
FossilOrigin-Name: 217f6e0c9c09c576b09ea59fce085a53d1a133927046102b4d00fd58109efc93
This commit is contained in:
@ -264,7 +264,9 @@ public class SQLTester {
|
||||
|
||||
void incrementTestCounter(){ ++nTest; ++nTotalTest; }
|
||||
|
||||
static final Pattern patternPlain = Pattern.compile("[\\W]", Pattern.MULTILINE);
|
||||
static final Pattern patternSpecial = Pattern.compile(
|
||||
"[\\x00-\\x20\\x22\\x5c\\x7b\\x7d]", Pattern.MULTILINE
|
||||
);
|
||||
static final Pattern patternSquiggly = Pattern.compile("[{}]", Pattern.MULTILINE);
|
||||
|
||||
/**
|
||||
@ -273,7 +275,7 @@ public class SQLTester {
|
||||
*/
|
||||
String escapeSqlValue(String v){
|
||||
if( "".equals(v) ) return "{}";
|
||||
Matcher m = patternPlain.matcher(v);
|
||||
Matcher m = patternSpecial.matcher(v);
|
||||
if( !m.find() ){
|
||||
return v /* no escaping needed */;
|
||||
}
|
||||
|
@ -125,9 +125,11 @@ appended to the result buffer according to the following rules:
|
||||
* If sqlite3_column_text() is an empty string, append `{}` to the
|
||||
result buffer and skip all subsequent rules.
|
||||
|
||||
* If sqlite3_column_text() does not contain any special characters
|
||||
(non-word characters), append it to the result buffer without
|
||||
any formatting and skip all subsequent rules.
|
||||
* If sqlite3_column_text() does not contain any special
|
||||
characters, append it to the result buffer without any
|
||||
formatting and skip all subsequent rules. Special characters are:
|
||||
0x00 to 0x20 (inclusive), double-quote (0x22), backslash (0x5c),
|
||||
curly braces (0x7b and 0x7d).
|
||||
|
||||
* If sqlite3_column_text() does not contains curly braces, then put
|
||||
the text inside of `{...}` and append it and skip all subsequent rules.
|
||||
|
@ -22,8 +22,9 @@ Also from the print command.
|
||||
SELECT 'a b', 'c';
|
||||
SELECT 'd', 'e';
|
||||
SELECT '{}', 'f';
|
||||
SELECT '{ }', 'g'
|
||||
--result {a b} c d e "{}" f "{\011}" g
|
||||
SELECT '{ }', 'g';
|
||||
SELECT '(a-b-c)', '[a-b-c]';
|
||||
--result {a b} c d e "{}" f "{\011}" g (a-b-c) [a-b-c]
|
||||
--testcase 2
|
||||
SELECT 123
|
||||
--glob 1#
|
||||
|
Reference in New Issue
Block a user