diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-01-10 09:33:47 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-01-10 09:33:47 +0000 |
commit | 73cd7b6697849b563a0154907b8a61c43e4ba209 (patch) | |
tree | c8889fa5acfcbb8ea726e55c39798dcce16a7741 /lib/webrick/accesslog.rb | |
parent | 9982c9298c10395a64429db5d433aae0c893c265 (diff) | |
download | ruby-73cd7b6697849b563a0154907b8a61c43e4ba209.tar.gz |
* lib/webrick/accesslog.rb : Escape needed.
* lib/webrick/httpstatus.rb : ditto.
* lib/webrick/httprequest.rb : ditto.
* lib/webrick/httputils.rb : ditto.
* test/webrick/test_cgi.rb (TestWEBrickCGI::test_bad_): Test for it.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/webrick/accesslog.rb')
-rw-r--r-- | lib/webrick/accesslog.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/webrick/accesslog.rb b/lib/webrick/accesslog.rb index f97769545e..75a3a3e694 100644 --- a/lib/webrick/accesslog.rb +++ b/lib/webrick/accesslog.rb @@ -53,15 +53,23 @@ module WEBrick when ?e, ?i, ?n, ?o raise AccessLogError, "parameter is required for \"#{spec}\"" unless param - params[spec][param] || "-" + param = params[spec][param] ? escape(param) : "-" when ?t params[spec].strftime(param || CLF_TIME_FORMAT) when ?% "%" else - params[spec] + escape(params[spec].to_s) end } end + + def escape(data) + if data.tainted? + data.gsub(/[[:cntrl:]\\]+/) {$&.dump[1...-1]}.untaint + else + data + end + end end end |