Author: jfrederic.clere(a)jboss.com
Date: 2009-01-20 08:19:00 -0500 (Tue, 20 Jan 2009)
New Revision: 2182
Modified:
trunk/mod_cluster/native/mod_manager/mod_manager.c
Log:
Copy the ap_proxy_hex2c into our code.
Modified: trunk/mod_cluster/native/mod_manager/mod_manager.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/mod_manager.c 2009-01-20 12:33:06 UTC (rev 2181)
+++ trunk/mod_cluster/native/mod_manager/mod_manager.c 2009-01-20 13:19:00 UTC (rev 2182)
@@ -1210,6 +1210,62 @@
* Decodes a '%' escaped string, and returns the number of characters
* (From mod_proxy_ftp.c).
*/
+
+/* already called in the knowledge that the characters are hex digits */
+/* Copied from modules/proxy/proxy_util.c */
+static int mod_manager_hex2c(const char *x)
+{
+ int i, ch;
+
+#if !APR_CHARSET_EBCDIC
+ ch = x[0];
+ if (apr_isdigit(ch)) {
+ i = ch - '0';
+ }
+ else if (apr_isupper(ch)) {
+ i = ch - ('A' - 10);
+ }
+ else {
+ i = ch - ('a' - 10);
+ }
+ i <<= 4;
+
+ ch = x[1];
+ if (apr_isdigit(ch)) {
+ i += ch - '0';
+ }
+ else if (apr_isupper(ch)) {
+ i += ch - ('A' - 10);
+ }
+ else {
+ i += ch - ('a' - 10);
+ }
+ return i;
+#else /*APR_CHARSET_EBCDIC*/
+ /*
+ * we assume that the hex value refers to an ASCII character
+ * so convert to EBCDIC so that it makes sense locally;
+ *
+ * example:
+ *
+ * client specifies %20 in URL to refer to a space char;
+ * at this point we're called with EBCDIC "20"; after turning
+ * EBCDIC "20" into binary 0x20, we then need to assume that 0x20
+ * represents an ASCII char and convert 0x20 to EBCDIC, yielding
+ * 0x40
+ */
+ char buf[1];
+
+ if (1 == sscanf(x, "%2x", &i)) {
+ buf[0] = i & 0xFF;
+ ap_xlate_proto_from_ascii(buf, 1);
+ return buf[0];
+ }
+ else {
+ return 0;
+ }
+#endif /*APR_CHARSET_EBCDIC*/
+}
static int decodeenc(char *x)
{
int i, j, ch;
@@ -1220,7 +1276,7 @@
/* decode it if not already done */
ch = x[i];
if (ch == '%' && apr_isxdigit(x[i + 1]) &&
apr_isxdigit(x[i + 2])) {
- ch = ap_proxy_hex2c(&x[i + 1]);
+ ch = mod_manager_hex2c(&x[i + 1]);
i += 2;
}
x[j] = ch;
Show replies by date