fluent-plugin-mail 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/fluent-plugin-mail.gemspec +4 -2
- data/lib/fluent/plugin/out_mail.rb +14 -1
- data/test/plugin/test_out_mail.rb +8 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c942140f8c65ac631eb04524fa56b7b9b3a828c
|
4
|
+
data.tar.gz: 13d63ce8f36b574c0918db98fd26f9e182a2412e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fe14ff31b1c4cb0bdd634ba6f399a45b761153090d057a601a595388d251661a93f43ea9bde2bb2a26fdeeb540da41289d3d9cce6957bc4389778c1a638b317
|
7
|
+
data.tar.gz: ea7f4254f6830d2119ff3fe12058f57d780d532f1cbcbf311d1e32eea7fe62f7e88cf4b9447470a384e303d2ce82f376f7a4ec14e8c3395b4bdd27d5f1434a74
|
data/CHANGELOG.md
CHANGED
data/fluent-plugin-mail.gemspec
CHANGED
@@ -12,7 +12,9 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
13
13
|
gem.name = "fluent-plugin-mail"
|
14
14
|
gem.require_paths = ["lib"]
|
15
|
-
gem.version = '0.1.
|
16
|
-
|
15
|
+
gem.version = '0.1.1'
|
16
|
+
|
17
17
|
gem.add_runtime_dependency "fluentd"
|
18
|
+
gem.add_runtime_dependency "string-scrub" if RUBY_VERSION.to_f < 2.1
|
19
|
+
gem.add_development_dependency "rake"
|
18
20
|
end
|
@@ -31,6 +31,7 @@ class Fluent::MailOutput < Fluent::Output
|
|
31
31
|
super
|
32
32
|
require 'net/smtp'
|
33
33
|
require 'kconv'
|
34
|
+
require 'string/scrub' if RUBY_VERSION.to_f < 2.1
|
34
35
|
end
|
35
36
|
|
36
37
|
def configure(conf)
|
@@ -136,7 +137,19 @@ class Fluent::MailOutput < Fluent::Output
|
|
136
137
|
end
|
137
138
|
end
|
138
139
|
|
139
|
-
(@message % values)
|
140
|
+
message = (@message % values)
|
141
|
+
with_scrub(message) {|str| str.gsub(/\\n/, "\n") }
|
142
|
+
end
|
143
|
+
|
144
|
+
def with_scrub(string)
|
145
|
+
begin
|
146
|
+
return yield(string)
|
147
|
+
rescue ArgumentError => e
|
148
|
+
raise e unless e.message.index("invalid byte sequence in") == 0
|
149
|
+
log.info "out_mail: invalid byte sequence is replaced in #{string}"
|
150
|
+
string.scrub!('?')
|
151
|
+
retry
|
152
|
+
end
|
140
153
|
end
|
141
154
|
|
142
155
|
def create_formatted_subject(tag, time, record)
|
@@ -75,5 +75,13 @@ class MailOutputTest < Test::Unit::TestCase
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
+
def test_with_scrub
|
79
|
+
d = create_driver(CONFIG_MESSAGE)
|
80
|
+
invalid_string = "\xff".force_encoding('UTF-8')
|
81
|
+
assert_nothing_raised {
|
82
|
+
res = d.instance.with_scrub(invalid_string) {|str| str.gsub(/\\n/, "\n") }
|
83
|
+
assert_equal '?', res
|
84
|
+
}
|
85
|
+
end
|
78
86
|
end
|
79
87
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-mail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuichi UEMURA
|
@@ -9,16 +9,16 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-01-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: fluentd
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0'
|
21
|
-
type: :
|
21
|
+
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
@@ -26,13 +26,13 @@ dependencies:
|
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: rake
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
|
-
type: :
|
35
|
+
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|