summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-23 09:44:05 +0000
committernahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-23 09:44:05 +0000
commit2f50fc74d58085ef3a711410371a080a96340453 (patch)
tree23289c850abfc8c7a6bf0c733e14b448e6a338b3
parent24d7cecd096f7f0c33e023fb25bdc2e347683cca (diff)
backported r26281 from ruby_1_8
* lib/webrick/accesslog.rb (WEBrick::AccessLog.format): log parameter embedding did not work. See #4913. * test/webrick/test_accesslog.rb: Add for test it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@32209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog9
-rw-r--r--lib/webrick/accesslog.rb2
-rw-r--r--test/webrick/test_accesslog.rb10
3 files changed, 20 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 99d5fded70..a8aefe3637 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Thu Jun 23 18:38:43 2011 Hiroshi Nakamura <nahi@ruby-lang.org>
+
+ backported r26281 from ruby_1_8
+
+ * lib/webrick/accesslog.rb (WEBrick::AccessLog.format): log parameter
+ embedding did not work. See #4913.
+
+ * test/webrick/test_accesslog.rb: Add for test it.
+
Thu Jun 16 22:55:02 2011 Hiroshi Nakamura <nahi@ruby-lang.org>
* test/test_securerandom.rb: Add testcase. This testcase does NOT aim
diff --git a/lib/webrick/accesslog.rb b/lib/webrick/accesslog.rb
index 75a3a3e694..0bed8097d5 100644
--- a/lib/webrick/accesslog.rb
+++ b/lib/webrick/accesslog.rb
@@ -53,7 +53,7 @@ module WEBrick
when ?e, ?i, ?n, ?o
raise AccessLogError,
"parameter is required for \"#{spec}\"" unless param
- param = params[spec][param] ? escape(param) : "-"
+ (param = params[spec][param]) ? escape(param) : "-"
when ?t
params[spec].strftime(param || CLF_TIME_FORMAT)
when ?%
diff --git a/test/webrick/test_accesslog.rb b/test/webrick/test_accesslog.rb
new file mode 100644
index 0000000000..15f0a9136b
--- /dev/null
+++ b/test/webrick/test_accesslog.rb
@@ -0,0 +1,10 @@
+require "test/unit"
+require "webrick/accesslog"
+
+class TestWEBrickAccessLog < Test::Unit::TestCase
+ def test_format
+ format = "%{Referer}i and %{User-agent}i"
+ params = {"i" => {"Referer" => "ref", "User-agent" => "agent"}}
+ assert_equal("ref and agent", WEBrick::AccessLog.format(format, params))
+ end
+end