httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Sutton <p...@ukweb.com>
Subject ErrorDocument fixes
Date Wed, 10 Jul 1996 11:38:01 GMT
Has anyone noticed a bug in ErrorDocument if you redirect to a local file
and the file doesn't exist? Try putting ErrorDocument 404
/missingfile.html and request a missing file - instead of the 404 message
text it'll just print /missingfile.html

I've made a patch to fix this. It reports it as a standard recursive error
(eg the original error, and then "Additionally, an error occuring
processing an ErrorDocument" or whatever). It also fixes the separate bug
which caused the leading quote (") to be output on custom-string error
documents. A final tidy-up of ErrorDocument handling would be to removed
the references to %s from the documentation, as previous reported.

I've kept the patch small and easy to read by not re-arranging the
if-statement affected. This has left a return in the middle of the
function and a {...} block which declares a couple of local variables.
This should probably be cleaned up before applying.

Paul
--
Paul Sutton
UK Web Ltd

*** ../../../apache_1.1.1/src/http_protocol.c   Sun Jun 23 19:05:16 1996
--- ./http_protocol.c   Wed Jul 10 13:30:03 1996
***************
*** 880,888 ****

      if (r->header_only) return;

!     if ((custom_response = response_code_string (r, idx)))
!         bputs(custom_response, c->client);
!     else {
        char *title = response_titles[idx];
        BUFF *fd = c->client;

--- 880,908 ----

      if (r->header_only) return;

!     if ((custom_response = response_code_string (r, idx))) {
!         /*
!        * We have a custom response output. This should only be
!        * a text-string to write back. But if the ErrorDocument
!        * was a local redirect and the requested resource failed
!        * for any reason, the custom_response will still hold the
!        * redirect URL. We don't really want to output this URL
!        * as a text message, so first check the custom response
!        * string to ensure that it is a text-string (using the
!        * same test used in die(), i.e. does it start with a
!        * "). If it doesn't, we've got a recursive error, so find
!        * the original error and output that as well.
!        */
!         if (custom_response[0] == '\"') {
!             bputs(custom_response+1, c->client);
!             return;
!       }
!       /* Redirect failed, so get back the original error and fall through
!        */
!       while (r->prev && r->prev->status != 200)
!           r = r->prev;
!     }
!     {
        char *title = response_titles[idx];
        BUFF *fd = c->client;






Mime
View raw message