Skip to content

Commit 9e0863a

Browse files
committed
docs: enumerate escaped chars in duplicate escape fns
Both escape_query_string copies now list the exact current set of escaped characters, making sync audits easier without needing to diff two files.
1 parent 9d635a4 commit 9e0863a

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

native/tantivy-c/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,13 +406,14 @@ fn string_to_c_string(s: &str) -> *mut c_char {
406406
}
407407
}
408408

409-
// Helper: Escape special characters in query strings to prevent injection (CWE-78)
409+
// Helper: Escape special characters in query strings to prevent query injection
410410
//
411411
// NOTE: This function is duplicated in src/tantivy/query_builder.inko
412412
// Both versions must be kept in sync. Any changes to the special character
413413
// list must be applied to both locations.
414414
//
415-
// Full list of Tantivy/Lucene special chars: " ' + - ( ) [ ] : * ? \ ^ ~ { } | ! and whitespace
415+
// Current escaped set (must match query_builder.inko::is_special_char):
416+
// " ' + - ( ) [ ] : * ? \ space ^ ~ { } | !
416417
fn escape_query_string(s: &str) -> String {
417418
let mut result = String::with_capacity(s.len() * 2);
418419
for c in s.chars() {

src/tantivy/query_builder.inko

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ impl TantivyQueryBuilder {
8181
# Both versions must be kept in sync. Any changes to the special character
8282
# list must be applied to both locations.
8383
#
84-
# Full list of Tantivy/Lucene special chars: " ' + - ( ) [ ] : * ? \ ^ ~ { } | ! and space
84+
# Current escaped set (must match lib.rs::escape_query_string):
85+
# " ' + - ( ) [ ] : * ? \ space ^ ~ { } | !
8586
fn escape_query_string(s: String) -> String {
8687
let mut buffer = StringBuffer.new
8788

0 commit comments

Comments
 (0)