File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -324,17 +324,26 @@ int fossil_io_validate_sanitize_string(const char *input,
324324 flags |= FOSSIL_SAN_BASE64 ;
325325
326326 /* Sanitization pass */
327+ int modified = 0 ;
327328 for (size_t i = 0 ; i < in_len && out_i < output_size - 1 ; i ++ ) {
328329 char c = input [i ];
329330 if (is_allowed (c )) {
330331 output [out_i ++ ] = c ;
331332 } else {
332333 output [out_i ++ ] = '_' ; /* neutralize */
333- flags |= FOSSIL_SAN_MODIFIED ;
334+ modified = 1 ;
334335 }
335336 }
336337 output [out_i ] = '\0' ;
337338
339+ /* Edge case: SQL context, but input contains SQL keywords with only allowed chars */
340+ if ((ctx == FOSSIL_CTX_SQL ) && (flags & FOSSIL_SAN_SQL ) && !modified ) {
341+ /* Force MODIFIED if SQL pattern detected but no chars were replaced */
342+ flags |= FOSSIL_SAN_MODIFIED ;
343+ } else if (modified ) {
344+ flags |= FOSSIL_SAN_MODIFIED ;
345+ }
346+
338347 return flags == 0 ? FOSSIL_SAN_OK : flags ;
339348}
340349
You can’t perform that action at this time.
0 commit comments