Fossil SCM

Do not allow non-alpha numeric ascii characters into the search pattern. Convert all such characters into a single space.

drh 2023-05-27 15:54 trunk
Commit 196dfedf7fc467cd98354fc9f163bae0f2a05c74850f0d4914ae7d4c6aa347e2
1 file changed +1 -1
+1 -1
--- src/search.c
+++ src/search.c
@@ -926,11 +926,11 @@
926926
static const char *zSnippetCall;
927927
if( srchFlags==0 ) return;
928928
sqlite3_create_function(g.db, "rank", 1, SQLITE_UTF8|SQLITE_INNOCUOUS, 0,
929929
search_rank_sqlfunc, 0, 0);
930930
for(i=0; zPat[i]; i++){
931
- if( zPat[i]=='-' || zPat[i]=='"' ) zPat[i] = ' ';
931
+ if( (zPat[i]&0x80)!=0 || !fossil_isalnum(zPat[i]) ) zPat[i] = ' ';
932932
}
933933
blob_init(&sql, 0, 0);
934934
if( search_index_type(0)==4 ){
935935
/* If this repo is still using the legacy FTS4 search index, then
936936
** the snippet() function is slightly different */
937937
--- src/search.c
+++ src/search.c
@@ -926,11 +926,11 @@
926 static const char *zSnippetCall;
927 if( srchFlags==0 ) return;
928 sqlite3_create_function(g.db, "rank", 1, SQLITE_UTF8|SQLITE_INNOCUOUS, 0,
929 search_rank_sqlfunc, 0, 0);
930 for(i=0; zPat[i]; i++){
931 if( zPat[i]=='-' || zPat[i]=='"' ) zPat[i] = ' ';
932 }
933 blob_init(&sql, 0, 0);
934 if( search_index_type(0)==4 ){
935 /* If this repo is still using the legacy FTS4 search index, then
936 ** the snippet() function is slightly different */
937
--- src/search.c
+++ src/search.c
@@ -926,11 +926,11 @@
926 static const char *zSnippetCall;
927 if( srchFlags==0 ) return;
928 sqlite3_create_function(g.db, "rank", 1, SQLITE_UTF8|SQLITE_INNOCUOUS, 0,
929 search_rank_sqlfunc, 0, 0);
930 for(i=0; zPat[i]; i++){
931 if( (zPat[i]&0x80)!=0 || !fossil_isalnum(zPat[i]) ) zPat[i] = ' ';
932 }
933 blob_init(&sql, 0, 0);
934 if( search_index_type(0)==4 ){
935 /* If this repo is still using the legacy FTS4 search index, then
936 ** the snippet() function is slightly different */
937

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button