Branch: Tag:

2012-09-24

2012-09-24 16:06:41 by Henrik Grubbström (Grubba) <grubba@grubba.org>

WEBDAV: Avoid replace() with dynamic second argument.

replace() and search() have a cache at the C-level that is only cleared on gc.
With a static cache key this doesn't matter much, but with a fully dynamic
key like in WEBDAV, the cache will have unlimited expansion.

The old code also erroneously could perform the replace multiple times.

Rev: server/base_server/module.pike:1.247

1:   // This file is part of Roxen WebServer.   // Copyright © 1996 - 2009, Roxen IS. - // $Id: module.pike,v 1.246 2012/07/02 10:05:18 mast Exp $ + // $Id: module.pike,v 1.247 2012/09/24 16:06:41 grubba Exp $      #include <module_constants.h>   #include <module.h>
488:    RequestID sub_id = id->clone_me();    sub_id->misc->common = id->misc->common;    -  sub_id->not_query = query_location() + path; -  sub_id->raw_url = replace (id->raw_url, id->not_query, sub_id->not_query); +  sub_id->raw_url = sub_id->not_query = query_location() + path; +  if ((sub_id->raw_url != id->raw_url) && (id->raw_url != id->not_query)) { +  // sub_id->raw_url = replace (id->raw_url, id->not_query, sub_id->not_query); +  sub_id->raw_url = sub_id->not_query + +  (({ "" }) + (id->raw_url/"?")[1..]) * "?"; +  }    sub_id->method = "HEAD";       mapping(string:mixed)|int(-1..0)|object res = find_file (path, sub_id);