Skip to content

Commit

Permalink
The fts3_tokenizer() function returns NULL if the
Browse files Browse the repository at this point in the history
SQLITE_DBCONFIG_ENABLE_FTS_TOKENIZER setting is disabled, which is is
by default.
  • Loading branch information
D. Richard Hipp committed Mar 1, 2019
1 parent 4d2ace3 commit e508ee1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
6 changes: 4 additions & 2 deletions ext/fts3/README.tokenizers
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@

SECURITY: If the fts3 extension is used in an environment where potentially
malicious users may execute arbitrary SQL (i.e. gears), they should be
prevented from invoking the fts3_tokenizer() function, possibly using the
authorisation callback.
prevented from invoking the fts3_tokenizer() function. The
fts3_tokenizer() function is disabled by default. It is only enabled
by SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER. Do not enable it in
security sensitive environments.

See "Sample code" below for an example of calling the fts3_tokenizer()
function from C code.
Expand Down
4 changes: 3 additions & 1 deletion ext/fts3/fts3_tokenizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ static void fts3TokenizerFunc(
return;
}
}
sqlite3_result_blob(context, (void *)&pPtr, sizeof(pPtr), SQLITE_TRANSIENT);
if( fts3TokenizerEnabled(context) ){
sqlite3_result_blob(context, (void *)&pPtr, sizeof(pPtr), SQLITE_TRANSIENT);
}
}

int sqlite3Fts3IsIdChar(char c){
Expand Down
4 changes: 2 additions & 2 deletions src/sqlite.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -2086,8 +2086,8 @@ struct sqlite3_mem_methods {
**
** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]]
** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
** <dd> ^This option is used to enable or disable the two-argument
** version of the [fts3_tokenizer()] function which is part of the
** <dd> ^This option is used to enable or disable the
** [fts3_tokenizer()] function which is part of the
** [FTS3] full-text search engine extension.
** There should be two additional arguments.
** The first argument is an integer which is 0 to disable fts3_tokenizer() or
Expand Down
1 change: 1 addition & 0 deletions test/fts3atoken.test
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ do_test fts3atoken-2.1 {
# simple input string via the built-in test function. This is as much
# to test the test function as the tokenizer implementations.
#
sqlite3_db_config db SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1
do_test fts3atoken-3.1 {
execsql {
SELECT fts3_tokenizer_test('simple', 'I don''t see how');
Expand Down

0 comments on commit e508ee1

Please sign in to comment.