]> cat aescling's git repositories - httpd-execline.git/commitdiff
Fix: Avoid catchall 500 on unsupported hostnames
authorcat æscling <aescling@cat.family>
Mon, 29 Apr 2024 23:01:49 +0000 (19:01 -0400)
committercat æscling <aescling@cat.family>
Mon, 29 Apr 2024 23:14:56 +0000 (19:14 -0400)
http-header-parse would exit failure (off the wrong side of an `if`)
when a hostname is declared unsuppurrted, triggering the overall `if`
wrapper to send a 500. this is concatenated to the already sent message,
resulting in a malformed document

the solution is to exit success on the unhappy path.

* Remove redundant backslashes
* Actually fix the bug

visible-to-httpd/binaries/http-header-parse.execline
visible-to-httpd/binaries/supported-hostname-test.execline

index 66d6be03b6d58a622af6323c734f51b0ceab396c..9d1a09c7a794b7297367fda1298942e1afb2bb19 100755 (executable)
@@ -132,7 +132,10 @@ case -N -- ${current_line_stripped} {
                        }
 
                        # short circuits on unsupported hostnames
-                       if { ${supported_hostname_test} ${header_contents} }
+                       ifelse -n { ${supported_hostname_test} ${header_contents} }
+                       {
+                               exit 0
+                       }
                                export http_header_parse_${header_name} ${header_contents}
                                ${0}
                                        ${supported_hostname_test}
index ed767b3008950027ba28e3fa6bd627f98b5e2d6a..de102c02d5c66cbc80138790f78d679fbc1ad7bd 100755 (executable)
@@ -6,8 +6,8 @@
 # immediately 404s otherwise
 
 ifelse {
-       eltest ! -d \supported_domains/${1} -o
-               ! -r \supported_domains/${1}
+       eltest ! -d supported_domains/${1} -o
+               ! -r supported_domains/${1}
 }
 {
        if {