hermeneutics 1.23 → 1.24
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/lib/hermeneutics/addrs.rb +5 -27
- data/lib/hermeneutics/cgi.rb +18 -22
- data/lib/hermeneutics/color.rb +1 -1
- data/lib/hermeneutics/contents.rb +9 -10
- data/lib/hermeneutics/escape.rb +17 -43
- data/lib/hermeneutics/message.rb +1 -5
- data/lib/hermeneutics/tags.rb +1 -1
- data/lib/hermeneutics/types.rb +6 -0
- data/lib/hermeneutics/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: df19436c205dec9d79e7ea6329b0039f73c0df18785684b3497a5beacba86de0
|
|
4
|
+
data.tar.gz: 71249e9f95d7d3b7a5cc4c69de6dcdf8d50312db07d6b4e06e75df798e24a7f6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 53de39c130f7134771b2ae8a03047ddd58ddf8daed8bf1b62e32f3627fe0125324e89a33aec4072cd38e4c5194261322e32d6069533fed8845c352982ca714fc
|
|
7
|
+
data.tar.gz: f3b02d37c1397fa5ddc2bf76247d85b1eef0d99a74d0c3afda583e97d1938ab1a7542c3ea557eec95c0deef199ddd1dfa5e73f3618598af009b8848f7def97d9
|
data/lib/hermeneutics/addrs.rb
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
=begin rdoc
|
|
8
8
|
|
|
9
|
-
:section: Classes
|
|
9
|
+
:section: Classes defined here
|
|
10
10
|
|
|
11
11
|
Hermeneutics::Addr is a single address
|
|
12
12
|
Hermeneutics::AddrList is a list of addresses in mail header fields.
|
|
@@ -306,22 +306,6 @@ module Hermeneutics
|
|
|
306
306
|
end
|
|
307
307
|
end
|
|
308
308
|
|
|
309
|
-
def lexer_decode str, &block
|
|
310
|
-
if block_given? then
|
|
311
|
-
HeaderExt.lexer str do |k,s|
|
|
312
|
-
case k
|
|
313
|
-
when :decoded then yield Token[ :char, s, true]
|
|
314
|
-
when :plain then lexer s, &block
|
|
315
|
-
when :space then yield Token[ :space]
|
|
316
|
-
end
|
|
317
|
-
end
|
|
318
|
-
else
|
|
319
|
-
r = []
|
|
320
|
-
lexer_decode str do |t| r.push t end
|
|
321
|
-
r
|
|
322
|
-
end
|
|
323
|
-
end
|
|
324
|
-
|
|
325
309
|
private
|
|
326
310
|
|
|
327
311
|
def escaped h, c
|
|
@@ -432,7 +416,7 @@ module Hermeneutics
|
|
|
432
416
|
# # "Möller, Fritz" <fmoeller@example.com>
|
|
433
417
|
#
|
|
434
418
|
def parse_decode str, &block
|
|
435
|
-
l = Token.
|
|
419
|
+
l = Token.lexer str
|
|
436
420
|
compile l, &block
|
|
437
421
|
end
|
|
438
422
|
|
|
@@ -577,7 +561,8 @@ module Hermeneutics
|
|
|
577
561
|
|
|
578
562
|
class <<self
|
|
579
563
|
def parse cont
|
|
580
|
-
|
|
564
|
+
str = HeaderExt.decode cont
|
|
565
|
+
new.add_quoted str
|
|
581
566
|
end
|
|
582
567
|
end
|
|
583
568
|
|
|
@@ -596,7 +581,7 @@ module Hermeneutics
|
|
|
596
581
|
def push addrs
|
|
597
582
|
case addrs
|
|
598
583
|
when nil then
|
|
599
|
-
when String then
|
|
584
|
+
when String then add_quoted addrs
|
|
600
585
|
when Addr then @list.push addrs
|
|
601
586
|
else addrs.each { |a| push a }
|
|
602
587
|
end
|
|
@@ -681,13 +666,6 @@ module Hermeneutics
|
|
|
681
666
|
self
|
|
682
667
|
end
|
|
683
668
|
|
|
684
|
-
def add_encoded cont
|
|
685
|
-
Addr.parse_decode cont.to_s do |a,|
|
|
686
|
-
@list.push a
|
|
687
|
-
end
|
|
688
|
-
self
|
|
689
|
-
end
|
|
690
|
-
|
|
691
669
|
end
|
|
692
670
|
|
|
693
671
|
end
|
data/lib/hermeneutics/cgi.rb
CHANGED
|
@@ -129,7 +129,7 @@ module Hermeneutics
|
|
|
129
129
|
|
|
130
130
|
def parameters nl: false, sym: false, strip: false
|
|
131
131
|
if block_given? then
|
|
132
|
-
|
|
132
|
+
parameter_data.parse do |k,v,**kw|
|
|
133
133
|
k = k.to_sym if sym
|
|
134
134
|
if v then
|
|
135
135
|
v.strip! if strip
|
|
@@ -146,33 +146,28 @@ module Hermeneutics
|
|
|
146
146
|
end
|
|
147
147
|
end
|
|
148
148
|
|
|
149
|
-
def
|
|
149
|
+
def parameter_data
|
|
150
150
|
case request_method
|
|
151
151
|
when "GET", "HEAD" then
|
|
152
|
-
Data::UrlEnc
|
|
152
|
+
dc, d = Data::UrlEnc, query_string
|
|
153
153
|
when "POST" then
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
warn "Content length #{content_length} is wrong (#{
|
|
154
|
+
d = $stdin.binmode.read
|
|
155
|
+
d.bytesize == content_length.to_i or
|
|
156
|
+
warn "Content length #{content_length} is wrong (#{d.bytesize})."
|
|
157
157
|
ct = ContentType.parse content_type
|
|
158
|
-
|
|
159
|
-
case ct.fulltype
|
|
160
|
-
when "application/x-www-form-urlencoded"
|
|
161
|
-
|
|
162
|
-
when "
|
|
163
|
-
|
|
164
|
-
when "
|
|
165
|
-
|
|
166
|
-
when "application/json" then
|
|
167
|
-
Data::Json.new data
|
|
168
|
-
when "application/x-yaml", "application/yaml" then
|
|
169
|
-
Data::Yaml.new data
|
|
170
|
-
else
|
|
171
|
-
Data::UrlEnc.new data
|
|
158
|
+
d.force_encoding ct[ :charset]||Encoding::ASCII_8BIT
|
|
159
|
+
dc = case ct.fulltype
|
|
160
|
+
when "application/x-www-form-urlencoded" then Data::UrlEnc
|
|
161
|
+
when "multipart/form-data" then a = [ ct.hash] ; Data::Multiparted
|
|
162
|
+
when "text/plain" then Data::Plain
|
|
163
|
+
when "application/json" then Data::Json
|
|
164
|
+
when "application/x-yaml", "application/yaml" then Data::Yaml
|
|
165
|
+
else Data::UrlEnc
|
|
172
166
|
end
|
|
173
167
|
else
|
|
174
|
-
Data::Lines
|
|
168
|
+
dc, d = Data::Lines, read_interactive
|
|
175
169
|
end
|
|
170
|
+
dc.new d, *a
|
|
176
171
|
end
|
|
177
172
|
|
|
178
173
|
|
|
@@ -208,8 +203,9 @@ module Hermeneutics
|
|
|
208
203
|
class Lines < Plain
|
|
209
204
|
def initialize lines
|
|
210
205
|
@lines = lines
|
|
206
|
+
super nil
|
|
211
207
|
end
|
|
212
|
-
def data ; @lines.join "\n" ; end
|
|
208
|
+
def data ; @data ||= @lines.join "\n" ; end
|
|
213
209
|
def parse
|
|
214
210
|
@lines.each { |s|
|
|
215
211
|
k, v = s.split %r/=/
|
data/lib/hermeneutics/color.rb
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
=begin rdoc
|
|
6
6
|
|
|
7
|
-
:section: Classes
|
|
7
|
+
:section: Classes defined here
|
|
8
8
|
|
|
9
9
|
Hermeneutics::Contents is a content field parser.
|
|
10
10
|
|
|
@@ -44,9 +44,9 @@ module Hermeneutics
|
|
|
44
44
|
# ds[ "a"] #=> "0123456"
|
|
45
45
|
#
|
|
46
46
|
def parse line
|
|
47
|
-
rest = line
|
|
48
|
-
|
|
49
|
-
new
|
|
47
|
+
rest = HeaderExt.decode line
|
|
48
|
+
rest.strip!
|
|
49
|
+
new *(build_args rest)
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
def urltext
|
|
@@ -55,7 +55,7 @@ module Hermeneutics
|
|
|
55
55
|
|
|
56
56
|
private
|
|
57
57
|
|
|
58
|
-
def
|
|
58
|
+
def build_args rest
|
|
59
59
|
hash = Hash.new { |h,k| h[ k] = [] }
|
|
60
60
|
asts = {}
|
|
61
61
|
while rest.notempty? do
|
|
@@ -66,6 +66,7 @@ module Hermeneutics
|
|
|
66
66
|
else
|
|
67
67
|
[ rest.dup, ""]
|
|
68
68
|
end
|
|
69
|
+
rest.lstrip!
|
|
69
70
|
key.downcase!
|
|
70
71
|
key = key.to_sym
|
|
71
72
|
asts[ key] = ast
|
|
@@ -91,7 +92,7 @@ module Hermeneutics
|
|
|
91
92
|
end
|
|
92
93
|
r[ k] = v
|
|
93
94
|
}
|
|
94
|
-
r
|
|
95
|
+
[ r]
|
|
95
96
|
end
|
|
96
97
|
|
|
97
98
|
end
|
|
@@ -236,11 +237,9 @@ module Hermeneutics
|
|
|
236
237
|
# c.caption #=> "text/html"
|
|
237
238
|
# c[ :boundary] #=> "0123456"
|
|
238
239
|
#
|
|
239
|
-
def
|
|
240
|
-
rest = line.strip
|
|
240
|
+
def build_args rest
|
|
241
241
|
caption, rest = rest.split Dictionary::RES, 2
|
|
242
|
-
|
|
243
|
-
new caption, hash
|
|
242
|
+
[ caption, *(super rest)]
|
|
244
243
|
end
|
|
245
244
|
|
|
246
245
|
end
|
data/lib/hermeneutics/escape.rb
CHANGED
|
@@ -9,7 +9,7 @@ require "supplement"
|
|
|
9
9
|
|
|
10
10
|
=begin rdoc
|
|
11
11
|
|
|
12
|
-
:section: Classes
|
|
12
|
+
:section: Classes defined here
|
|
13
13
|
|
|
14
14
|
Hermeneutics::Entities encodes to and decodes from HTML-Entities
|
|
15
15
|
(+&+ etc.)
|
|
@@ -401,11 +401,12 @@ module Hermeneutics
|
|
|
401
401
|
#
|
|
402
402
|
def mkurl path, hash = nil, anchor = nil
|
|
403
403
|
unless Hash === hash then
|
|
404
|
-
hash, anchor = anchor,
|
|
404
|
+
hash, anchor = anchor, nil
|
|
405
405
|
end
|
|
406
|
-
r = "
|
|
407
|
-
r <<
|
|
408
|
-
r << "
|
|
406
|
+
r = ""
|
|
407
|
+
r << path.to_s
|
|
408
|
+
r << "?" << (encode_hash hash) if hash
|
|
409
|
+
r << "#" << anchor.to_s if anchor
|
|
409
410
|
r
|
|
410
411
|
end
|
|
411
412
|
|
|
@@ -726,28 +727,18 @@ module Hermeneutics
|
|
|
726
727
|
#
|
|
727
728
|
def decode str
|
|
728
729
|
r, e = [], []
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
elsif l == :plain then
|
|
737
|
-
r.push SPACE
|
|
738
|
-
end
|
|
739
|
-
when :space then
|
|
740
|
-
nil
|
|
741
|
-
when :plain then
|
|
742
|
-
if l == :decoded then
|
|
743
|
-
r.push SPACE
|
|
744
|
-
end
|
|
730
|
+
loop do
|
|
731
|
+
if str =~ /=\?([a-z0-9_-]+?)\?([QB])\?([!-~]+?)\?=/i then
|
|
732
|
+
p = $`
|
|
733
|
+
d = unmask $1, $2, $3
|
|
734
|
+
str = $'
|
|
735
|
+
else
|
|
736
|
+
p = str
|
|
745
737
|
end
|
|
746
|
-
r.push
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
r.pop
|
|
738
|
+
r.push p if p =~ /\S/
|
|
739
|
+
d or break
|
|
740
|
+
r.push d
|
|
741
|
+
e.push d.encoding
|
|
751
742
|
end
|
|
752
743
|
e.uniq!
|
|
753
744
|
begin
|
|
@@ -760,23 +751,6 @@ module Hermeneutics
|
|
|
760
751
|
end
|
|
761
752
|
end
|
|
762
753
|
|
|
763
|
-
def lexer str
|
|
764
|
-
while str do
|
|
765
|
-
str =~ /(\s+)|\B=\?(\S*?)\?([QB])\?(\S*?)\?=\B/i
|
|
766
|
-
if $1 then
|
|
767
|
-
yield :plain, $` unless $`.empty?
|
|
768
|
-
yield :space, $&
|
|
769
|
-
elsif $2 then
|
|
770
|
-
yield :plain, $` unless $`.empty?
|
|
771
|
-
d = unmask $2, $3, $4
|
|
772
|
-
yield :decoded, d
|
|
773
|
-
else
|
|
774
|
-
yield :plain, str
|
|
775
|
-
end
|
|
776
|
-
str = $'.notempty?
|
|
777
|
-
end
|
|
778
|
-
end
|
|
779
|
-
|
|
780
754
|
private
|
|
781
755
|
|
|
782
756
|
def unmask cs, tp, txt
|
data/lib/hermeneutics/message.rb
CHANGED
|
@@ -146,11 +146,7 @@ module Hermeneutics
|
|
|
146
146
|
|
|
147
147
|
def contents type = nil
|
|
148
148
|
if type then
|
|
149
|
-
|
|
150
|
-
if not @contents.is_a? type then
|
|
151
|
-
@contents = type.parse @data
|
|
152
|
-
end
|
|
153
|
-
else
|
|
149
|
+
unless @contents and (@contents.is_a? type) then
|
|
154
150
|
@contents = type.parse @data
|
|
155
151
|
end
|
|
156
152
|
else
|
data/lib/hermeneutics/tags.rb
CHANGED
data/lib/hermeneutics/types.rb
CHANGED
data/lib/hermeneutics/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hermeneutics
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '1.
|
|
4
|
+
version: '1.24'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bertram Scharpf
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: supplement
|
|
@@ -78,7 +77,6 @@ homepage: http://www.bertram-scharpf.de
|
|
|
78
77
|
licenses:
|
|
79
78
|
- BSD-2-Clause
|
|
80
79
|
metadata: {}
|
|
81
|
-
post_install_message:
|
|
82
80
|
rdoc_options:
|
|
83
81
|
- "--charset"
|
|
84
82
|
- utf-8
|
|
@@ -98,8 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
98
96
|
version: '0'
|
|
99
97
|
requirements:
|
|
100
98
|
- Ruby, at least 3.0
|
|
101
|
-
rubygems_version: 3.
|
|
102
|
-
signing_key:
|
|
99
|
+
rubygems_version: 3.7.1
|
|
103
100
|
specification_version: 4
|
|
104
101
|
summary: CGI and mail handling
|
|
105
102
|
test_files: []
|