martin      98/09/14 09:10:30

  Modified:    src/main util_script.c
  Log:
  Add error message on EBCDIC machines if CGI script outputs ASCII headers
  
  Revision  Changes    Path
  1.131     +21 -0     apache-1.3/src/main/util_script.c
  
  Index: util_script.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/main/util_script.c,v
  retrieving revision 1.130
  retrieving revision 1.131
  diff -u -r1.130 -r1.131
  --- util_script.c     1998/09/03 22:40:41     1.130
  +++ util_script.c     1998/09/14 16:10:22     1.131
  @@ -505,6 +505,27 @@
   
        /* if we see a bogus header don't ignore it. Shout and scream */
   
  +#ifdef CHARSET_EBCDIC
  +         /* Chances are that we received an ASCII header text instead of
  +          * the expected EBCDIC header lines. Try to auto-detect:
  +          */
  +     if (!(l = strchr(w, ':'))) {
  +         int maybeASCII = 0, maybeEBCDIC = 0;
  +         char *cp;
  +
  +         for (cp = w; *cp != '\0'; ++cp) {
  +             if (isprint(*cp) && !isprint(os_toebcdic[*cp]))
  +                 ++maybeEBCDIC;
  +             if (!isprint(*cp) && isprint(os_toebcdic[*cp]))
  +                 ++maybeASCII;
  +             }
  +         if (maybeASCII > maybeEBCDIC) {
  +             ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server,
  +                      "CGI Interface Error: Script headers apparently ASCII: 
(CGI = %s)", r->filename);
  +             ascii2ebcdic(w, w, cp - w);
  +         }
  +     }
  +#endif
        if (!(l = strchr(w, ':'))) {
            char malformed[(sizeof MALFORMED_MESSAGE) + 1
                           + MALFORMED_HEADER_LENGTH_TO_SHOW];
  
  
  

Reply via email to