From 79b59d2badae724fa407bec8ac246c3f3de2127f Mon Sep 17 00:00:00 2001 From: Kenji Okimoto Date: Fri, 25 Nov 2016 15:18:47 +0900 Subject: [PATCH] Store regexp options properly --- lib/fluent/compat/parser.rb | 2 ++ test/compat/test_parser.rb | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/fluent/compat/parser.rb b/lib/fluent/compat/parser.rb index b47a47f418..64e5068dc3 100644 --- a/lib/fluent/compat/parser.rb +++ b/lib/fluent/compat/parser.rb @@ -168,6 +168,8 @@ def configure(conf) return if @manually_configured # not to run twice conf['expression'] ||= @stored_regexp.source + conf['ignorecase'] ||= @stored_regexp.options & Regexp::IGNORECASE != 0 + conf['multiline'] ||= @stored_regexp.options & Regexp::MULTILINE != 0 convert_type_converter_parameters!(conf) super diff --git a/test/compat/test_parser.rb b/test/compat/test_parser.rb index 52c6c4ff32..4d5ba27dec 100644 --- a/test/compat/test_parser.rb +++ b/test/compat/test_parser.rb @@ -79,4 +79,14 @@ def test_setting_estimate_current_event_value p2.configure('format' => 'none') assert_equal false, p2.parser.estimate_current_event end + + data(ignorecase: Regexp::IGNORECASE, + multiline: Regexp::MULTILINE, + both: Regexp::IGNORECASE & Regexp::MULTILINE) + def test_regexp_parser_config(options) + source = "a" + parser = Fluent::TextParser::RegexpParser.new(Regexp.new(source, options), { "dummy" => "dummy" }) + regexp = parser.instance_variable_get("@regexp") + assert_equal(options, regexp.options) + end end