]> granicus.if.org Git - apache/commitdiff
insure that canned error msgs are translated to ascii before leaving
authorGreg Ames <gregames@apache.org>
Mon, 26 Feb 2001 22:07:00 +0000 (22:07 +0000)
committerGreg Ames <gregames@apache.org>
Mon, 26 Feb 2001 22:07:00 +0000 (22:07 +0000)
an ebcdic server in worst case scenarios.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@88361 13f79535-47bb-0310-9956-ffa450edef68

include/util_ebcdic.h
modules/http/http_protocol.c
server/util_ebcdic.c

index 7cc01941d469414c249d4017678b5c23acc525d8..6dae00b4edd3aa5a3c011f6452db948c2501da34 100644 (file)
@@ -96,6 +96,14 @@ void ap_xlate_proto_to_ascii(char *buffer, apr_size_t len);
  */
 void ap_xlate_proto_from_ascii(char *buffer, apr_size_t len);
 
+/**
+ * Convert protocol data from the implementation charater
+ * set to ASCII, then send it.
+ * @param r   the current request
+ * @param ... the strings to write, followed by a NULL pointer
+ */
+int ap_rvputs_proto_in_ascii(request_rec *r, ...);
+
 #ifdef __cplusplus
 }
 #endif
@@ -105,6 +113,8 @@ void ap_xlate_proto_from_ascii(char *buffer, apr_size_t len);
 #define ap_xlate_proto_to_ascii(x,y)          /* NOOP */
 #define ap_xlate_proto_from_ascii(x,y)        /* NOOP */
 
+#define ap_rvputs_proto_in_ascii  ap_rvputs
+
 #endif  /* APR_CHARSET_EBCDIC */
     
 #endif  /* !APACHE_UTIL_EBCDIC_H */
index 4d06da3c9673f325f14d9b1a2514b1388c5a13c6..c678eb743ea1edbfd67a58e358a8ef0714074c6d 100644 (file)
@@ -2043,22 +2043,28 @@ AP_DECLARE(void) ap_send_error_response(request_rec *r, int recursive_error)
         /* folks decided they didn't want the error code in the H1 text */
         h1 = &title[4];
 
-        ap_rvputs(rlast,
+        /* can't count on a charset filter being in place here, 
+         * so do ebcdic->ascii translation explicity (if needed)
+         */
+
+        ap_rvputs_proto_in_ascii(rlast,
                   DOCTYPE_HTML_2_0
                   "<HTML><HEAD>\n<TITLE>", title,
                   "</TITLE>\n</HEAD><BODY>\n<H1>", h1, "</H1>\n",
                   NULL);
         
-        ap_rputs(get_canned_error_string(status, r, location),rlast); 
+        ap_rvputs_proto_in_ascii(rlast,
+                                 get_canned_error_string(status, r, location),
+                                 NULL); 
 
         if (recursive_error) {
-            ap_rvputs(rlast, "<P>Additionally, a ",
+            ap_rvputs_proto_in_ascii(rlast, "<P>Additionally, a ",
                       status_lines[ap_index_of_response(recursive_error)],
                       "\nerror was encountered while trying to use an "
                       "ErrorDocument to handle the request.\n", NULL);
         }
-        ap_rputs(ap_psignature("<HR>\n", r), rlast);
-        ap_rputs("</BODY></HTML>\n", rlast);
+        ap_rvputs_proto_in_ascii(rlast, ap_psignature("<HR>\n", r), NULL);
+        ap_rvputs_proto_in_ascii(rlast, "</BODY></HTML>\n", NULL);
     }
     ap_finalize_request_protocol(r);
 }
index 447ba6ef83c2070d92a2075575d0e34a18e3ba75..75a1b7dd3d7ce07ddce852367b0afd2fe11424ac 100644 (file)
@@ -141,4 +141,28 @@ void ap_xlate_proto_from_ascii(char *buffer, apr_size_t len)
                           buffer, &outbytes_left);
 }
 
+int ap_rvputs_proto_in_ascii(request_rec *r, ...)
+{
+    va_list va;
+    const char *s;
+    char *ascii_s;
+    apr_size_t len;
+    apr_size_t written = 0;
+
+    va_start(va, r);
+    while (1) {
+        s = va_arg(va, const char *);
+        if (s == NULL)
+            break;
+        len = strlen(s);
+        ascii_s = apr_pstrndup(r->pool, s, len);
+        ap_xlate_proto_to_ascii(ascii_s, len);
+        if (ap_rputs(ascii_s, r) < 0)
+            return -1;
+        written += len;
+    }
+    va_end(va);
+    return written;
+}    
 #endif /* APR_CHARSET_EBCDIC */