File tree Expand file tree Collapse file tree
crates/bin/docs_rs_web/src/middleware Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,6 +50,11 @@ fn validate_decoded_path(path: &str) -> Result<()> {
5050 bail ! ( "detected `#` in request path" ) ;
5151 }
5252
53+ // `<` and `>` are never allowed — they indicate HTML injection attempts.
54+ if path. contains ( '<' ) || path. contains ( '>' ) {
55+ bail ! ( "detected `<` or `>` in request path" ) ;
56+ }
57+
5358 Ok ( ( ) )
5459}
5560
@@ -78,6 +83,9 @@ mod tests {
7883 #[ test_case(
7984 "/crate/mika-cli/latest/source/..%25c1%259c..%25c1%259c..%25c1%259c..%25c1%259c..%25c1%259c..%25c1%259c..%25c1%259c..%25c1%259c/etc/passwd"
8085 ) ]
86+ #[ test_case(
87+ "/mathru/0.10.0/i686-unknown-linux-gnu/mathru/special/hypergeometric/%3E%3Cscript%20defer%20src=%22https:/cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.js%22%20integrity=%22sha384-2BKqo+exmr9su6dir+qCw08N2ZKRucY4PrGQPP..."
88+ ) ]
8189 async fn test_invalid_path ( path : & str ) -> Result < ( ) > {
8290 let app = Router :: new ( )
8391 . route ( "/{*inner}" , get ( || async { StatusCode :: OK } ) )
You can’t perform that action at this time.
0 commit comments