components/apache24/patches/bug60577.patch
branchs11u3-sru
changeset 7591 ba368fc828e6
equal deleted inserted replaced
7588:0891c3ebad2b 7591:ba368fc828e6
       
     1 https://bz.apache.org/bugzilla/show_bug.cgi?id=60577
       
     2 
       
     3 Index: modules/cache/cache_util.c
       
     4 ===================================================================
       
     5 --- modules/cache/cache_util.c	(revision 1778044)
       
     6 +++ modules/cache/cache_util.c	(working copy)
       
     7 @@ -31,10 +31,8 @@ extern module AP_MODULE_DECLARE_DATA cache_module;
       
     8   * in "filter". All but the path comparisons are case-insensitive.
       
     9   */
       
    10  static int uri_meets_conditions(const apr_uri_t *filter, const int pathlen,
       
    11 -                                request_rec *r)
       
    12 +                                const apr_uri_t *url)
       
    13  {
       
    14 -    const apr_uri_t *url = &r->parsed_uri;
       
    15 -
       
    16      /* Scheme, hostname port and local part. The filter URI and the
       
    17       * URI we test may have the following shapes:
       
    18       *   /<path>
       
    19 @@ -114,7 +112,7 @@ static int uri_meets_conditions(const apr_uri_t *f
       
    20      /* For HTTP caching purposes, an empty (NULL) path is equivalent to
       
    21       * a single "/" path. RFCs 3986/2396
       
    22       */
       
    23 -    if (!r->uri) {
       
    24 +    if (!url->path) {
       
    25          if (*filter->path == '/' && pathlen == 1) {
       
    26              return 1;
       
    27          }
       
    28 @@ -126,7 +124,7 @@ static int uri_meets_conditions(const apr_uri_t *f
       
    29      /* Url has met all of the filter conditions so far, determine
       
    30       * if the paths match.
       
    31       */
       
    32 -    return !strncmp(filter->path, r->uri, pathlen);
       
    33 +    return !strncmp(filter->path, url->path, pathlen);
       
    34  }
       
    35  
       
    36  static cache_provider_list *get_provider(request_rec *r, struct cache_enable *ent,
       
    37 @@ -172,6 +170,7 @@ cache_provider_list *cache_get_providers(request_r
       
    38  {
       
    39      cache_dir_conf *dconf = ap_get_module_config(r->per_dir_config, &cache_module);
       
    40      cache_provider_list *providers = NULL;
       
    41 +    const apr_uri_t *url;
       
    42      int i;
       
    43  
       
    44      /* per directory cache disable */
       
    45 @@ -179,11 +178,25 @@ cache_provider_list *cache_get_providers(request_r
       
    46          return NULL;
       
    47      }
       
    48  
       
    49 +    url = &r->parsed_uri;
       
    50 +    if (url->path != r->uri || (r->uri && strcmp(url->path, r->uri))) {
       
    51 +        apr_uri_t *uri = apr_pcalloc(r->pool, sizeof *uri);
       
    52 +        if (r->uri && apr_uri_parse(r->pool, r->uri, uri)) {
       
    53 +            return NULL;
       
    54 +        }
       
    55 +        if (!uri->scheme) {
       
    56 +            char *path = uri->path;
       
    57 +            memcpy(uri, url, sizeof *uri);
       
    58 +            uri->path = path;
       
    59 +        }
       
    60 +        url = uri;
       
    61 +    }
       
    62 +
       
    63      /* global cache disable */
       
    64      for (i = 0; i < conf->cachedisable->nelts; i++) {
       
    65          struct cache_disable *ent =
       
    66                                 (struct cache_disable *)conf->cachedisable->elts;
       
    67 -        if (uri_meets_conditions(&ent[i].url, ent[i].pathlen, r)) {
       
    68 +        if (uri_meets_conditions(&ent[i].url, ent[i].pathlen, url)) {
       
    69              /* Stop searching now. */
       
    70              return NULL;
       
    71          }
       
    72 @@ -200,7 +213,7 @@ cache_provider_list *cache_get_providers(request_r
       
    73      for (i = 0; i < conf->cacheenable->nelts; i++) {
       
    74          struct cache_enable *ent =
       
    75                                  (struct cache_enable *)conf->cacheenable->elts;
       
    76 -        if (uri_meets_conditions(&ent[i].url, ent[i].pathlen, r)) {
       
    77 +        if (uri_meets_conditions(&ent[i].url, ent[i].pathlen, url)) {
       
    78              providers = get_provider(r, &ent[i], providers);
       
    79          }
       
    80      }