From: Hiroshi NAKAMURA Date: 2011-06-20T16:54:04+09:00 Subject: [ruby-core:37237] [Ruby 1.9 - Bug #3869][Closed] Logger#log does not handle or escape new-line characters. Issue #3869 has been updated by Hiroshi NAKAMURA. Status changed from Assigned to Closed Sorry for keeping this ticket open. I thought logger.info ["User-input: %{input}", input: data] looks good, though I like logger.info "User-input: %{input}", input: data better. But I cannot find the compatible way to extend Logger to support it. Plus, we can write like; logger.info "User-input: %p" % data logger.info "User-input: %{input}" % input: data Back to escaping issue, I close this ticket since we add RDoc about it. ---------------------------------------- Bug #3869: Logger#log does not handle or escape new-line characters. http://redmine.ruby-lang.org/issues/3869 Author: Hal Brodigan Status: Closed Priority: Normal Assignee: Hiroshi NAKAMURA Category: lib Target version: ruby -v: ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux] =begin The Logger#log method does not escape or handle new-line characters properly. By not logging each line of the log message, or escaping the new-line characters, one could forge false log messages. >> logger = Logger.new(STDOUT) >> logger.log Logger::INFO, "hello\nworld" I, [2010-09-23T12:28:09.612508 #6122] INFO -- : hello world => true >> logger.log Logger::INFO, "Fault detected!\nI, [2010-09-23T12:28:09.612508 #6122] INFO -- : Fault was false-positive, ignoring ..." I, [2010-09-23T12:32:57.757877 #6122] INFO -- : Fault detected! I, [2010-09-23T12:28:09.612508 #6122] INFO -- : Fault was false-positive, ignoring ... => true =end -- http://redmine.ruby-lang.org