diff options
author | makoto kuwata <kwa@kuwata-lab.com> | 2010-06-29 23:14:33 +0900 |
---|---|---|
committer | makoto kuwata <kwa@kuwata-lab.com> | 2010-06-29 23:14:33 +0900 |
commit | 54cf76b40c52211860645215ea69ffb76f9d986c (patch) | |
tree | 6a31484d40012340f6a77da95cc320e3bc6e9eb5 | |
parent | d2617bf014d32c48cc0cd1e32c2159fec9423809 (diff) | |
download | erubis-54cf76b40c52211860645215ea69ffb76f9d986c.tar.gz |
[enhance] index.cgi to expand '~user' path
-rw-r--r-- | contrib/index.cgi | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/contrib/index.cgi b/contrib/index.cgi index cf3080b..7a0a57b 100644 --- a/contrib/index.cgi +++ b/contrib/index.cgi @@ -49,7 +49,9 @@ begin request_uri = ENV['REQUEST_URI'] or raise "ENV['REQUEST_URI'] is not set." ## get filepath basepath = request_uri.split(/\?/, 2).first - filepath = File.join(document_root, basepath) + filepath = basepath =~ /\A\/(~[-.\w]+)/ \ + ? File.join(File.expand_path($1), "public_html", $') \ + : File.join(document_root, basepath) filepath.gsub!(/\.html\z/, '.rhtml') or # expected '*.html' raise HttpError.new('500 Internal Error', 'invalid .htaccess configuration.') File.file?(filepath) or # file not found |