89c94b
diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c
89c94b
index fb897a9..38dbb24 100644
89c94b
--- a/modules/mappers/mod_rewrite.c
89c94b
+++ b/modules/mappers/mod_rewrite.c
89c94b
@@ -619,6 +619,13 @@ static unsigned is_absolute_uri(char *uri, int *supportsqs)
89c94b
             return 6;
89c94b
         }
89c94b
         break;
89c94b
+
89c94b
+    case 'u':
89c94b
+    case 'U':
89c94b
+        if (!ap_cstr_casecmpn(uri, "nix:", 4)) {        /* unix:     */
89c94b
+            *sqs = 1;
89c94b
+            return (uri[4] == '/' && uri[5] == '/') ? 7 : 5;
89c94b
+        }
89c94b
     }
89c94b
 
89c94b
     return 0;
89c94b
diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c
89c94b
index f383996..6a9ef55 100644
89c94b
--- a/modules/proxy/mod_proxy.c
89c94b
+++ b/modules/proxy/mod_proxy.c
89c94b
@@ -1717,7 +1717,8 @@ PROXY_DECLARE(const char *) ap_proxy_de_socketfy(apr_pool_t *p, const char *url)
89c94b
      * the UDS path... ignore it
89c94b
      */
89c94b
     if (!strncasecmp(url, "unix:", 5) &&
89c94b
-        ((ptr = ap_strchr_c(url, '|')) != NULL)) {
89c94b
+        ((ptr = ap_strchr_c(url + 5, '|')) != NULL)) {
89c94b
+
89c94b
         /* move past the 'unix:...|' UDS path info */
89c94b
         const char *ret, *c;
89c94b
 
89c94b
diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c
89c94b
index 7714b6c..3dd570c 100644
89c94b
--- a/modules/proxy/proxy_util.c
89c94b
+++ b/modules/proxy/proxy_util.c
89c94b
@@ -2084,33 +2084,45 @@ static int ap_proxy_retry_worker(const char *proxy_function, proxy_worker *worke
89c94b
  * were passed a UDS url (eg: from mod_proxy) and adjust uds_path
89c94b
  * as required.  
89c94b
  */
89c94b
-static void fix_uds_filename(request_rec *r, char **url) 
89c94b
+static int fix_uds_filename(request_rec *r, char **url) 
89c94b
 {
89c94b
-    char *ptr, *ptr2;
89c94b
-    if (!r || !r->filename) return;
89c94b
+    char *uds_url = r->filename + 6, *origin_url;
89c94b
 
89c94b
     if (!strncmp(r->filename, "proxy:", 6) &&
89c94b
-            (ptr2 = ap_strcasestr(r->filename, "unix:")) &&
89c94b
-            (ptr = ap_strchr(ptr2, '|'))) {
89c94b
+            !ap_cstr_casecmpn(uds_url, "unix:", 5) &&
89c94b
+            (origin_url = ap_strchr(uds_url + 5, '|'))) {
89c94b
+        char *uds_path = NULL;
89c94b
+        apr_size_t url_len;
89c94b
         apr_uri_t urisock;
89c94b
         apr_status_t rv;
89c94b
-        *ptr = '\0';
89c94b
-        rv = apr_uri_parse(r->pool, ptr2, &urisock);
89c94b
-        if (rv == APR_SUCCESS) {
89c94b
-            char *rurl = ptr+1;
89c94b
-            char *sockpath = ap_runtime_dir_relative(r->pool, urisock.path);
89c94b
-            apr_table_setn(r->notes, "uds_path", sockpath);
89c94b
-            *url = apr_pstrdup(r->pool, rurl); /* so we get the scheme for the uds */
89c94b
-            /* r->filename starts w/ "proxy:", so add after that */
89c94b
-            memmove(r->filename+6, rurl, strlen(rurl)+1);
89c94b
-            ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
89c94b
-                    "*: rewrite of url due to UDS(%s): %s (%s)",
89c94b
-                    sockpath, *url, r->filename);
89c94b
-        }
89c94b
-        else {
89c94b
-            *ptr = '|';
89c94b
-        }
89c94b
-    }
89c94b
+
89c94b
+        *origin_url = '\0';
89c94b
+        rv = apr_uri_parse(r->pool, uds_url, &urisock);
89c94b
+        *origin_url++ = '|';
89c94b
+
89c94b
+        if (rv == APR_SUCCESS && urisock.path && (!urisock.hostname
89c94b
+                                                  || !urisock.hostname[0])) {
89c94b
+             uds_path = ap_runtime_dir_relative(r->pool, urisock.path);
89c94b
+        }
89c94b
+
89c94b
+        if (!uds_path) {
89c94b
+             ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(10292)
89c94b
+                     "Invalid proxy UDS filename (%s)", r->filename);
89c94b
+             return 0;
89c94b
+        }
89c94b
+        apr_table_setn(r->notes, "uds_path", uds_path);
89c94b
+
89c94b
+        /* Remove the UDS path from *url and r->filename */
89c94b
+        url_len = strlen(origin_url);
89c94b
+        *url = apr_pstrmemdup(r->pool, origin_url, url_len);
89c94b
+        memcpy(uds_url, *url, url_len + 1);
89c94b
+
89c94b
+        ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
89c94b
+                 "*: rewrite of url due to UDS(%s): %s (%s)",
89c94b
+                 uds_path, *url, r->filename);
89c94b
+     }
89c94b
+
89c94b
+     return 1;
89c94b
 }
89c94b
 
89c94b
 PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
89c94b
@@ -2128,7 +2140,9 @@ PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
89c94b
                           "%s: found worker %s for %s",
89c94b
                           (*worker)->s->scheme, (*worker)->s->name, *url);
89c94b
             *balancer = NULL;
89c94b
-            fix_uds_filename(r, url);
89c94b
+            if (!fix_uds_filename(r, url)) {
89c94b
+                     return HTTP_INTERNAL_SERVER_ERROR;
89c94b
+            }
89c94b
             access_status = OK;
89c94b
         }
89c94b
         else if (r->proxyreq == PROXYREQ_PROXY) {
89c94b
@@ -2159,7 +2173,9 @@ PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
89c94b
                  * regarding the Connection header in the request.
89c94b
                  */
89c94b
                 apr_table_setn(r->subprocess_env, "proxy-nokeepalive", "1");
89c94b
-                fix_uds_filename(r, url);
89c94b
+                if (!fix_uds_filename(r, url)) {
89c94b
+                     return HTTP_INTERNAL_SERVER_ERROR;
89c94b
+                }
89c94b
             }
89c94b
         }
89c94b
     }