From 71718791cebc0525a48aa0f4e7ab4ed334e7d1e2 Mon Sep 17 00:00:00 2001 From: Martin Dietze Date: Mon, 23 Jul 2018 18:43:39 +0800 Subject: [PATCH] Teach exception_detector.rb to deal with escaped tabs (\u0009) in JSON streams of Java exceptions (#33: Escaped characters U+0000..001F in JSON not dealt with correctly). --- lib/fluent/plugin/exception_detector.rb | 6 +-- test/plugin/test_exception_detector.rb | 68 +++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 3 deletions(-) diff --git a/lib/fluent/plugin/exception_detector.rb b/lib/fluent/plugin/exception_detector.rb index 96e41e7..841bb41 100644 --- a/lib/fluent/plugin/exception_detector.rb +++ b/lib/fluent/plugin/exception_detector.rb @@ -53,9 +53,9 @@ def self.supported rule(:start_state, /(?:Exception|Error|Throwable|V8 errors stack trace)[:\r\n]/, :java), - rule(:java, /^[\t ]+(?:eval )?at /, :java), - rule(:java, /^[\t ]*(?:Caused by|Suppressed):/, :java), - rule(:java, /^[\t ]*... \d+\ more/, :java) + rule(:java, /^(\\u0009|[\t ])+(?:eval )?at /, :java), + rule(:java, /^(\\u0009|[\t ])*(?:Caused by|Suppressed):/, :java), + rule(:java, /^(\\u0009|[\t ])*... \d+\ more/, :java) ].freeze PYTHON_RULES = [ diff --git a/test/plugin/test_exception_detector.rb b/test/plugin/test_exception_detector.rb index e260c9e..24bf244 100644 --- a/test/plugin/test_exception_detector.rb +++ b/test/plugin/test_exception_detector.rb @@ -30,6 +30,70 @@ class ExceptionDetectorTest < Test::Unit::TestCase JAVA_EXC = (JAVA_EXC_PART1 + JAVA_EXC_PART2).freeze + COMPLEX_JAVA_EXC_TABS = <