From ae5a5016be550100eba342ebd2232ed00718f65a Mon Sep 17 00:00:00 2001 From: Masahiro Nakagawa Date: Thu, 27 Apr 2017 08:06:09 +0900 Subject: [PATCH] Allow null byte in double-quoted string. fix #1358 --- lib/fluent/config/literal_parser.rb | 2 ++ test/config/test_literal_parser.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/fluent/config/literal_parser.rb b/lib/fluent/config/literal_parser.rb index 67db779461..3af66d54c3 100644 --- a/lib/fluent/config/literal_parser.rb +++ b/lib/fluent/config/literal_parser.rb @@ -181,6 +181,8 @@ def eval_escape_char(c) "\f" when "b" "\b" + when "0" + "\0" when /[a-zA-Z0-9]/ parse_error! "unexpected back-slash escape character '#{c}'" else # symbols diff --git a/test/config/test_literal_parser.rb b/test/config/test_literal_parser.rb index 3e495fe332..ae8d0e9cf1 100644 --- a/test/config/test_literal_parser.rb +++ b/test/config/test_literal_parser.rb @@ -105,8 +105,8 @@ def test_falseX test('"\\.t"') { assert_text_parsed_as(".t", '"\\.t"') } test('"\\$t"') { assert_text_parsed_as("$t", '"\\$t"') } test('"\\"') { assert_text_parsed_as("#t", '"\\#t"') } + test('"\\0"') { assert_text_parsed_as("\0", '"\\0"') } test('"\\z"') { assert_parse_error('"\\z"') } # unknown escaped character - test('"\\0"') { assert_parse_error('"\\0"') } # unknown escaped character test('"\\1"') { assert_parse_error('"\\1"') } # unknown escaped character test('"t') { assert_parse_error('"t') } # non-terminated quoted character test("\"t\nt\"") { assert_text_parsed_as("t\nt", "\"t\nt\"" ) } # multiline string