]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
http: restore behavior for event http.uri_delim_non_compliant
authorPhilippe Antoine <pantoine@oisf.net>
Sat, 5 Apr 2025 19:22:25 +0000 (21:22 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 7 Apr 2025 12:21:35 +0000 (14:21 +0200)
If we see a space-like character that is not space 0x20 in uri,
we set this event, even it the request line finished with a normal
space and protocol

Fixes: 9c324b796e6b ("http: Use libhtp-rs.)
rust/htp/src/request.rs

index c26dfe797cf51d706cbb35ba6d60de34f5511369..56fe02db118fec6352e0d0904271d5afc13e083a 100644 (file)
@@ -961,22 +961,24 @@ impl ConnectionParser {
                     *c == 0x20
                 });
 
-            if uri.len() == remaining.len() && uri.iter().any(|&c| is_space(c)) {
+            if uri.iter().any(|&c| is_space(c) && c != 0x20) {
                 // warn regardless if we've seen non-compliant chars
                 htp_warn!(
                     self.logger,
                     HtpLogCode::URI_DELIM_NON_COMPLIANT,
                     "Request line: URI contains non-compliant delimiter"
                 );
-                // if we've seen some 'bad' delimiters, we retry with those
-                let uri_protocol = split_on_predicate(
-                    remaining,
-                    self.cfg.decoder_cfg.allow_space_uri,
-                    true,
-                    |c| is_space(*c),
-                );
-                uri = uri_protocol.0;
-                protocol = uri_protocol.1;
+                if uri.len() == remaining.len() {
+                    // if we've seen some 'bad' delimiters, we retry with those
+                    let uri_protocol = split_on_predicate(
+                        remaining,
+                        self.cfg.decoder_cfg.allow_space_uri,
+                        true,
+                        |c| is_space(*c),
+                    );
+                    uri = uri_protocol.0;
+                    protocol = uri_protocol.1;
+                }
             }
 
             let req = self.request_mut().unwrap();