postfix_status_line 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -4
- data/ext/postfix_status_line_core.c +36 -10
- data/lib/postfix_status_line.rb +3 -3
- data/lib/postfix_status_line/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba1d3cc388e6481f1a89bae81c03f0964e2edac3
|
4
|
+
data.tar.gz: 2aeacc192ab96a747017c8befeef4609e8be0896
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea847a0a7d39284df8f02f94e41575d5561495367b48fd9c767e434504067d5b540d248ad935da826dc088eccb04e3e4561f6217d7e3263c1af5bfa47fc5813e
|
7
|
+
data.tar.gz: 2797537e8eb181261ea00bfc6ecf535633a89f1bf4f5e6af440b2885b413c4a3c99f33830657f641d749126db82cacfdd07bde614c0141e5e1226819f40bc989
|
data/README.md
CHANGED
@@ -63,9 +63,7 @@ PostfixStatusLine.parse(status_line, hash: true, sha_algorithm: 256)
|
|
63
63
|
PostfixStatusLine.parse(status_line, parse_time: true)
|
64
64
|
```
|
65
65
|
|
66
|
-
### Parse
|
67
|
-
|
68
|
-
see http://www.postfix.org/header_checks.5.html
|
66
|
+
### Parse [header_checks](http://www.postfix.org/header_checks.5.html)
|
69
67
|
|
70
68
|
```ruby
|
71
69
|
warning = "Mar 4 14:44:19 P788 postfix/cleanup[7426]: E80A9DF6F7E: warning: header Subject: test from local; from=<sugawara@P788.local> to=<sgwr_dts@yahoo.co.jp>"
|
@@ -79,7 +77,8 @@ PostfixStatusLine.parse_header_checks_warning(warning)
|
|
79
77
|
# "to"=>"********@yahoo.co.jp",
|
80
78
|
# "domain"=>"yahoo.co.jp",
|
81
79
|
# "from"=>"********@P788.local",
|
82
|
-
# "
|
80
|
+
# "header_from"=>"local",
|
81
|
+
# "Subject"=>"test"
|
83
82
|
# }
|
84
83
|
```
|
85
84
|
|
@@ -273,18 +273,45 @@ static void split_line2(char *str, bool mask, VALUE hash, bool include_hash, cha
|
|
273
273
|
}
|
274
274
|
}
|
275
275
|
|
276
|
-
static void put_header(char *str, VALUE hash, bool mask) {
|
277
|
-
if (
|
276
|
+
static void put_header(char *str, size_t len, VALUE hash, bool mask) {
|
277
|
+
if (str[len - 1] != ';') {
|
278
278
|
return;
|
279
279
|
}
|
280
280
|
|
281
|
-
str
|
282
|
-
|
281
|
+
char *without_cmd = strchr(str, ':');
|
282
|
+
|
283
|
+
if (without_cmd == NULL) {
|
284
|
+
return;
|
285
|
+
}
|
286
|
+
|
287
|
+
if (strncmp(without_cmd, ": header ", 9) != 0) {
|
288
|
+
return;
|
289
|
+
}
|
290
|
+
|
291
|
+
char *value = strchr(without_cmd + 9, ':');
|
283
292
|
|
284
293
|
if (value == NULL || *(value + 1) == '\0') {
|
285
294
|
return;
|
286
295
|
}
|
287
296
|
|
297
|
+
*without_cmd = '\0';
|
298
|
+
without_cmd += 9;
|
299
|
+
|
300
|
+
int i;
|
301
|
+
|
302
|
+
for (i = (int) len - 2; i >= 0; i--) {
|
303
|
+
if (str[i] == ' ') {
|
304
|
+
char *chunk = str + i + 1;
|
305
|
+
|
306
|
+
if (strncmp(chunk, "from ", 5) == 0) {
|
307
|
+
str[len - 1] = '\0';
|
308
|
+
rb_hash_aset(hash, rb_str_new2("header_from"), rb_str_new2(chunk + 5));
|
309
|
+
str[i] = '\0';
|
310
|
+
break;
|
311
|
+
}
|
312
|
+
}
|
313
|
+
}
|
314
|
+
|
288
315
|
if (mask) {
|
289
316
|
mask_email(value);
|
290
317
|
}
|
@@ -292,9 +319,8 @@ static void put_header(char *str, VALUE hash, bool mask) {
|
|
292
319
|
*value = '\0';
|
293
320
|
value += 2;
|
294
321
|
|
295
|
-
|
296
|
-
|
297
|
-
rb_hash_aset(hash, v_key, v_value);
|
322
|
+
rb_hash_aset(hash, rb_str_new2("priority"), rb_str_new2(str));
|
323
|
+
rb_hash_aset(hash, rb_str_new2(without_cmd), rb_str_new2(value));
|
298
324
|
}
|
299
325
|
|
300
326
|
static void split_line3(char *str, bool mask, VALUE hash, bool include_hash, char *salt, size_t salt_len, DIGEST_SHA digest_sha_func) {
|
@@ -312,7 +338,7 @@ static void split_line3(char *str, bool mask, VALUE hash, bool include_hash, cha
|
|
312
338
|
} else if (strncmp(chunk, "from=", 5) == 0) {
|
313
339
|
put_attr(chunk, hash, mask, include_hash, salt, salt_len, digest_sha_func);
|
314
340
|
ptr[i] = '\0';
|
315
|
-
put_header(ptr, hash, mask);
|
341
|
+
put_header(ptr, i, hash, mask);
|
316
342
|
break;
|
317
343
|
}
|
318
344
|
}
|
@@ -483,7 +509,7 @@ static VALUE rb_postfix_status_line_parse(VALUE self, VALUE v_str, VALUE v_mask,
|
|
483
509
|
return hash;
|
484
510
|
}
|
485
511
|
|
486
|
-
static VALUE
|
512
|
+
static VALUE rb_postfix_status_line_parse_header_checks(VALUE self, VALUE v_str, VALUE v_mask, VALUE v_hash, VALUE v_salt, VALUE v_parse_time, VALUE v_sha_algo) {
|
487
513
|
char *str;
|
488
514
|
size_t len;
|
489
515
|
bool mask;
|
@@ -517,5 +543,5 @@ void Init_postfix_status_line_core() {
|
|
517
543
|
VALUE rb_mPostfixStatusLine = rb_define_module("PostfixStatusLine");
|
518
544
|
VALUE rb_mPostfixStatusLineCore = rb_define_module_under(rb_mPostfixStatusLine, "Core");
|
519
545
|
rb_define_module_function(rb_mPostfixStatusLineCore, "parse", rb_postfix_status_line_parse, 6);
|
520
|
-
rb_define_module_function(rb_mPostfixStatusLineCore, "
|
546
|
+
rb_define_module_function(rb_mPostfixStatusLineCore, "parse_header_checks", rb_postfix_status_line_parse_header_checks, 6);
|
521
547
|
}
|
data/lib/postfix_status_line.rb
CHANGED
@@ -14,13 +14,13 @@ module PostfixStatusLine
|
|
14
14
|
end
|
15
15
|
module_function :parse
|
16
16
|
|
17
|
-
def
|
17
|
+
def parse_header_checks(str, options = {})
|
18
18
|
mask = options.has_key?(:mask) ? options[:mask] : true
|
19
19
|
hash = options[:hash]
|
20
20
|
salt = options[:salt]
|
21
21
|
parse_time = options[:parse_time]
|
22
22
|
sha_algo = options[:sha_algorithm]
|
23
|
-
PostfixStatusLine::Core.
|
23
|
+
PostfixStatusLine::Core.parse_header_checks(str, mask, hash, salt, parse_time, sha_algo)
|
24
24
|
end
|
25
|
-
module_function :
|
25
|
+
module_function :parse_header_checks
|
26
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postfix_status_line
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|