actionmailer-rack-upgrade 2.3.14.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +387 -0
- data/MIT-LICENSE +21 -0
- data/README +149 -0
- data/Rakefile +97 -0
- data/install.rb +30 -0
- data/lib/action_mailer/adv_attr_accessor.rb +30 -0
- data/lib/action_mailer/base.rb +739 -0
- data/lib/action_mailer/helpers.rb +113 -0
- data/lib/action_mailer/mail_helper.rb +17 -0
- data/lib/action_mailer/part.rb +107 -0
- data/lib/action_mailer/part_container.rb +55 -0
- data/lib/action_mailer/quoting.rb +62 -0
- data/lib/action_mailer/test_case.rb +64 -0
- data/lib/action_mailer/test_helper.rb +68 -0
- data/lib/action_mailer/utils.rb +7 -0
- data/lib/action_mailer/vendor/text-format-0.6.3/text/format.rb +1466 -0
- data/lib/action_mailer/vendor/text_format.rb +10 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/Makefile +18 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/address.rb +392 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/attachments.rb +65 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/base64.rb +46 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/compat.rb +41 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/config.rb +67 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/core_extensions.rb +63 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/encode.rb +590 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/header.rb +962 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/index.rb +9 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/interface.rb +1162 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/loader.rb +3 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/mail.rb +578 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/mailbox.rb +496 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/main.rb +6 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/mbox.rb +3 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/net.rb +250 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/obsolete.rb +132 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/parser.rb +1060 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/parser.y +416 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/port.rb +379 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/quoting.rb +164 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/require_arch.rb +58 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/scanner.rb +49 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/scanner_r.rb +262 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/stringio.rb +280 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/utils.rb +362 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/COPYING +504 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/README +12 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/big5freq.rb +927 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/big5prober.rb +42 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/chardistribution.rb +238 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/charsetgroupprober.rb +112 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/charsetprober.rb +75 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/codingstatemachine.rb +64 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/constants.rb +42 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/escprober.rb +89 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/escsm.rb +244 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/eucjpprober.rb +88 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/euckrfreq.rb +596 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/euckrprober.rb +42 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/euctwfreq.rb +430 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/euctwprober.rb +42 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/gb2312freq.rb +474 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/gb2312prober.rb +42 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/hebrewprober.rb +289 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/jisfreq.rb +570 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/jpcntx.rb +229 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/langbulgarianmodel.rb +229 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/langcyrillicmodel.rb +330 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/langgreekmodel.rb +227 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/langhebrewmodel.rb +202 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/langhungarianmodel.rb +226 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/langthaimodel.rb +201 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/latin1prober.rb +147 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/mbcharsetprober.rb +89 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/mbcsgroupprober.rb +45 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/mbcssm.rb +542 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/sbcharsetprober.rb +124 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/sbcsgroupprober.rb +56 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/sjisprober.rb +88 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/universaldetector.rb +168 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/utf8prober.rb +87 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet.rb +67 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail/version.rb +39 -0
- data/lib/action_mailer/vendor/tmail-1.2.7/tmail.rb +6 -0
- data/lib/action_mailer/vendor/tmail.rb +17 -0
- data/lib/action_mailer/version.rb +9 -0
- data/lib/action_mailer.rb +62 -0
- data/lib/actionmailer.rb +2 -0
- data/test/abstract_unit.rb +62 -0
- data/test/asset_host_test.rb +54 -0
- data/test/delivery_method_test.rb +51 -0
- data/test/fixtures/asset_host_mailer/email_with_asset.html.erb +1 -0
- data/test/fixtures/auto_layout_mailer/hello.html.erb +1 -0
- data/test/fixtures/auto_layout_mailer/multipart.text.html.erb +1 -0
- data/test/fixtures/auto_layout_mailer/multipart.text.plain.erb +1 -0
- data/test/fixtures/explicit_layout_mailer/logout.html.erb +1 -0
- data/test/fixtures/explicit_layout_mailer/signup.html.erb +1 -0
- data/test/fixtures/first_mailer/share.erb +1 -0
- data/test/fixtures/helper_mailer/use_example_helper.erb +1 -0
- data/test/fixtures/helper_mailer/use_helper.erb +1 -0
- data/test/fixtures/helper_mailer/use_helper_method.erb +1 -0
- data/test/fixtures/helper_mailer/use_mail_helper.erb +5 -0
- data/test/fixtures/helpers/example_helper.rb +5 -0
- data/test/fixtures/layouts/auto_layout_mailer.html.erb +1 -0
- data/test/fixtures/layouts/auto_layout_mailer.text.erb +1 -0
- data/test/fixtures/layouts/spam.html.erb +1 -0
- data/test/fixtures/path.with.dots/funky_path_mailer/multipart_with_template_path_with_dots.erb +1 -0
- data/test/fixtures/raw_email +14 -0
- data/test/fixtures/raw_email10 +20 -0
- data/test/fixtures/raw_email12 +32 -0
- data/test/fixtures/raw_email13 +29 -0
- data/test/fixtures/raw_email2 +114 -0
- data/test/fixtures/raw_email3 +70 -0
- data/test/fixtures/raw_email4 +59 -0
- data/test/fixtures/raw_email5 +19 -0
- data/test/fixtures/raw_email6 +20 -0
- data/test/fixtures/raw_email7 +66 -0
- data/test/fixtures/raw_email8 +47 -0
- data/test/fixtures/raw_email9 +28 -0
- data/test/fixtures/raw_email_quoted_with_0d0a +14 -0
- data/test/fixtures/raw_email_with_invalid_characters_in_content_type +104 -0
- data/test/fixtures/raw_email_with_nested_attachment +100 -0
- data/test/fixtures/raw_email_with_partially_quoted_subject +14 -0
- data/test/fixtures/second_mailer/share.erb +1 -0
- data/test/fixtures/templates/signed_up.erb +3 -0
- data/test/fixtures/test_mailer/_subtemplate.text.plain.erb +1 -0
- data/test/fixtures/test_mailer/body_ivar.erb +2 -0
- data/test/fixtures/test_mailer/custom_templating_extension.text.html.haml +6 -0
- data/test/fixtures/test_mailer/custom_templating_extension.text.plain.haml +6 -0
- data/test/fixtures/test_mailer/implicitly_multipart_example.ignored.erb +1 -0
- data/test/fixtures/test_mailer/implicitly_multipart_example.rhtml.bak +1 -0
- data/test/fixtures/test_mailer/implicitly_multipart_example.text.html.erb +10 -0
- data/test/fixtures/test_mailer/implicitly_multipart_example.text.html.erb~ +10 -0
- data/test/fixtures/test_mailer/implicitly_multipart_example.text.plain.erb +2 -0
- data/test/fixtures/test_mailer/implicitly_multipart_example.text.yaml.erb +1 -0
- data/test/fixtures/test_mailer/included_subtemplate.text.plain.erb +1 -0
- data/test/fixtures/test_mailer/rxml_template.builder +2 -0
- data/test/fixtures/test_mailer/rxml_template.rxml +2 -0
- data/test/fixtures/test_mailer/signed_up.html.erb +3 -0
- data/test/fixtures/test_mailer/signed_up_with_url.erb +5 -0
- data/test/mail_helper_test.rb +95 -0
- data/test/mail_layout_test.rb +123 -0
- data/test/mail_render_test.rb +116 -0
- data/test/mail_service_test.rb +1145 -0
- data/test/quoting_test.rb +105 -0
- data/test/test_helper_test.rb +129 -0
- data/test/tmail_test.rb +22 -0
- data/test/url_test.rb +76 -0
- metadata +209 -0
data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/latin1prober.rb
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
######################## BEGIN LICENSE BLOCK ########################
|
2
|
+
# The Original Code is Mozilla Universal charset detector code.
|
3
|
+
#
|
4
|
+
# The Initial Developer of the Original Code is
|
5
|
+
# Netscape Communications Corporation.
|
6
|
+
# Portions created by the Initial Developer are Copyright (C) 2001
|
7
|
+
# the Initial Developer. All Rights Reserved.
|
8
|
+
#
|
9
|
+
# Contributor(s):
|
10
|
+
# Jeff Hodges - port to Ruby
|
11
|
+
# Mark Pilgrim - port to Python
|
12
|
+
# Shy Shalom - original C code
|
13
|
+
#
|
14
|
+
# This library is free software; you can redistribute it and/or
|
15
|
+
# modify it under the terms of the GNU Lesser General Public
|
16
|
+
# License as published by the Free Software Foundation; either
|
17
|
+
# version 2.1 of the License, or (at your option) any later version.
|
18
|
+
#
|
19
|
+
# This library is distributed in the hope that it will be useful,
|
20
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
21
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
22
|
+
# Lesser General Public License for more details.
|
23
|
+
#
|
24
|
+
# You should have received a copy of the GNU Lesser General Public
|
25
|
+
# License along with this library; if not, write to the Free Software
|
26
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
27
|
+
# 02110-1301 USA
|
28
|
+
######################### END LICENSE BLOCK #########################
|
29
|
+
|
30
|
+
module CharDet
|
31
|
+
FREQ_CAT_NUM = 4
|
32
|
+
|
33
|
+
UDF = 0 # undefined
|
34
|
+
OTH = 1 # other
|
35
|
+
ASC = 2 # ascii capital letter
|
36
|
+
ASS = 3 # ascii small letter
|
37
|
+
ACV = 4 # accent capital vowel
|
38
|
+
ACO = 5 # accent capital other
|
39
|
+
ASV = 6 # accent small vowel
|
40
|
+
ASO = 7 # accent small other
|
41
|
+
CLASS_NUM = 8 # total classes
|
42
|
+
|
43
|
+
Latin1_CharToClass = [
|
44
|
+
OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 00 - 07
|
45
|
+
OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 08 - 0F
|
46
|
+
OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 10 - 17
|
47
|
+
OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 18 - 1F
|
48
|
+
OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 20 - 27
|
49
|
+
OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 28 - 2F
|
50
|
+
OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 30 - 37
|
51
|
+
OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 38 - 3F
|
52
|
+
OTH, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 40 - 47
|
53
|
+
ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 48 - 4F
|
54
|
+
ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 50 - 57
|
55
|
+
ASC, ASC, ASC, OTH, OTH, OTH, OTH, OTH, # 58 - 5F
|
56
|
+
OTH, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 60 - 67
|
57
|
+
ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 68 - 6F
|
58
|
+
ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 70 - 77
|
59
|
+
ASS, ASS, ASS, OTH, OTH, OTH, OTH, OTH, # 78 - 7F
|
60
|
+
OTH, UDF, OTH, ASO, OTH, OTH, OTH, OTH, # 80 - 87
|
61
|
+
OTH, OTH, ACO, OTH, ACO, UDF, ACO, UDF, # 88 - 8F
|
62
|
+
UDF, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 90 - 97
|
63
|
+
OTH, OTH, ASO, OTH, ASO, UDF, ASO, ACO, # 98 - 9F
|
64
|
+
OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # A0 - A7
|
65
|
+
OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # A8 - AF
|
66
|
+
OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # B0 - B7
|
67
|
+
OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # B8 - BF
|
68
|
+
ACV, ACV, ACV, ACV, ACV, ACV, ACO, ACO, # C0 - C7
|
69
|
+
ACV, ACV, ACV, ACV, ACV, ACV, ACV, ACV, # C8 - CF
|
70
|
+
ACO, ACO, ACV, ACV, ACV, ACV, ACV, OTH, # D0 - D7
|
71
|
+
ACV, ACV, ACV, ACV, ACV, ACO, ACO, ACO, # D8 - DF
|
72
|
+
ASV, ASV, ASV, ASV, ASV, ASV, ASO, ASO, # E0 - E7
|
73
|
+
ASV, ASV, ASV, ASV, ASV, ASV, ASV, ASV, # E8 - EF
|
74
|
+
ASO, ASO, ASV, ASV, ASV, ASV, ASV, OTH, # F0 - F7
|
75
|
+
ASV, ASV, ASV, ASV, ASV, ASO, ASO, ASO, # F8 - FF
|
76
|
+
]
|
77
|
+
|
78
|
+
# 0 : illegal
|
79
|
+
# 1 : very unlikely
|
80
|
+
# 2 : normal
|
81
|
+
# 3 : very likely
|
82
|
+
Latin1ClassModel = [
|
83
|
+
# UDF OTH ASC ASS ACV ACO ASV ASO
|
84
|
+
0, 0, 0, 0, 0, 0, 0, 0, # UDF
|
85
|
+
0, 3, 3, 3, 3, 3, 3, 3, # OTH
|
86
|
+
0, 3, 3, 3, 3, 3, 3, 3, # ASC
|
87
|
+
0, 3, 3, 3, 1, 1, 3, 3, # ASS
|
88
|
+
0, 3, 3, 3, 1, 2, 1, 2, # ACV
|
89
|
+
0, 3, 3, 3, 3, 3, 3, 3, # ACO
|
90
|
+
0, 3, 1, 3, 1, 1, 1, 3, # ASV
|
91
|
+
0, 3, 1, 3, 1, 1, 3, 3, # ASO
|
92
|
+
]
|
93
|
+
|
94
|
+
class Latin1Prober < CharSetProber
|
95
|
+
def initialize
|
96
|
+
super
|
97
|
+
reset()
|
98
|
+
end
|
99
|
+
|
100
|
+
def reset
|
101
|
+
@_mLastCharClass = OTH
|
102
|
+
@_mFreqCounter = [0] * FREQ_CAT_NUM
|
103
|
+
super
|
104
|
+
end
|
105
|
+
|
106
|
+
def get_charset_name
|
107
|
+
return "windows-1252"
|
108
|
+
end
|
109
|
+
|
110
|
+
def feed(aBuf)
|
111
|
+
aBuf = filter_with_english_letters(aBuf)
|
112
|
+
aBuf.each_byte do |b|
|
113
|
+
c = b.chr
|
114
|
+
charClass = Latin1_CharToClass[c[0]]
|
115
|
+
freq = Latin1ClassModel[(@_mLastCharClass * CLASS_NUM) + charClass]
|
116
|
+
if freq == 0
|
117
|
+
@_mState = ENotMe
|
118
|
+
break
|
119
|
+
end
|
120
|
+
@_mFreqCounter[freq] += 1
|
121
|
+
@_mLastCharClass = charClass
|
122
|
+
end
|
123
|
+
|
124
|
+
return get_state()
|
125
|
+
end
|
126
|
+
|
127
|
+
def get_confidence
|
128
|
+
if get_state() == ENotMe
|
129
|
+
return 0.01
|
130
|
+
end
|
131
|
+
|
132
|
+
total = @_mFreqCounter.inject{|a,b| a+b}
|
133
|
+
if total < 0.01
|
134
|
+
confidence = 0.0
|
135
|
+
else
|
136
|
+
confidence = (@_mFreqCounter[3] / total) - (@_mFreqCounter[1] * 20.0 / total)
|
137
|
+
end
|
138
|
+
if confidence < 0.0
|
139
|
+
confidence = 0.0
|
140
|
+
end
|
141
|
+
# lower the confidence of latin1 so that other more accurate detector
|
142
|
+
# can take priority.
|
143
|
+
confidence = confidence * 0.5
|
144
|
+
return confidence
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/mbcharsetprober.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
######################## BEGIN LICENSE BLOCK ########################
|
2
|
+
# The Original Code is Mozilla Universal charset detector code.
|
3
|
+
#
|
4
|
+
# The Initial Developer of the Original Code is
|
5
|
+
# Netscape Communications Corporation.
|
6
|
+
# Portions created by the Initial Developer are Copyright (C) 2001
|
7
|
+
# the Initial Developer. All Rights Reserved.
|
8
|
+
#
|
9
|
+
# Contributor(s):
|
10
|
+
# Jeff Hodges - port to Ruby
|
11
|
+
# Mark Pilgrim - port to Python
|
12
|
+
# Shy Shalom - original C code
|
13
|
+
# Proofpoint, Inc.
|
14
|
+
#
|
15
|
+
# This library is free software; you can redistribute it and/or
|
16
|
+
# modify it under the terms of the GNU Lesser General Public
|
17
|
+
# License as published by the Free Software Foundation; either
|
18
|
+
# version 2.1 of the License, or (at your option) any later version.
|
19
|
+
#
|
20
|
+
# This library is distributed in the hope that it will be useful,
|
21
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
22
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
23
|
+
# Lesser General Public License for more details.
|
24
|
+
#
|
25
|
+
# You should have received a copy of the GNU Lesser General Public
|
26
|
+
# License along with this library; if not, write to the Free Software
|
27
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
28
|
+
# 02110-1301 USA
|
29
|
+
######################### END LICENSE BLOCK #########################
|
30
|
+
|
31
|
+
module CharDet
|
32
|
+
class MultiByteCharSetProber < CharSetProber
|
33
|
+
def initialize
|
34
|
+
super
|
35
|
+
@_mDistributionAnalyzer = nil
|
36
|
+
@_mCodingSM = nil
|
37
|
+
@_mLastChar = "\x00\x00"
|
38
|
+
end
|
39
|
+
|
40
|
+
def reset
|
41
|
+
super
|
42
|
+
if @_mCodingSM
|
43
|
+
@_mCodingSM.reset()
|
44
|
+
end
|
45
|
+
if @_mDistributionAnalyzer
|
46
|
+
@_mDistributionAnalyzer.reset()
|
47
|
+
end
|
48
|
+
@_mLastChar = "\x00\x00"
|
49
|
+
end
|
50
|
+
|
51
|
+
def get_charset_name
|
52
|
+
end
|
53
|
+
|
54
|
+
def feed(aBuf)
|
55
|
+
aLen = aBuf.length
|
56
|
+
for i in (0...aLen)
|
57
|
+
codingState = @_mCodingSM.next_state(aBuf[i..i])
|
58
|
+
if codingState == EError
|
59
|
+
$stderr << "#{get_charset_name} prober hit error at byte #{i}\n" if $debug
|
60
|
+
@_mState = ENotMe
|
61
|
+
break
|
62
|
+
elsif codingState == EItsMe
|
63
|
+
@_mState = EFoundIt
|
64
|
+
break
|
65
|
+
elsif codingState == EStart
|
66
|
+
charLen = @_mCodingSM.get_current_charlen()
|
67
|
+
if i == 0
|
68
|
+
@_mLastChar[1] = aBuf[0..0]
|
69
|
+
@_mDistributionAnalyzer.feed(@_mLastChar, charLen)
|
70
|
+
else
|
71
|
+
@_mDistributionAnalyzer.feed(aBuf[i-1...i+1], charLen)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
@_mLastChar[0] = aBuf[aLen-1..aLen-1]
|
76
|
+
|
77
|
+
if get_state() == EDetecting
|
78
|
+
if @_mDistributionAnalyzer.got_enough_data() and (get_confidence() > SHORTCUT_THRESHOLD)
|
79
|
+
@_mState = EFoundIt
|
80
|
+
end
|
81
|
+
end
|
82
|
+
return get_state()
|
83
|
+
end
|
84
|
+
|
85
|
+
def get_confidence
|
86
|
+
return @_mDistributionAnalyzer.get_confidence()
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/mbcsgroupprober.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
######################## BEGIN LICENSE BLOCK ########################
|
2
|
+
# The Original Code is Mozilla Universal charset detector code.
|
3
|
+
#
|
4
|
+
# The Initial Developer of the Original Code is
|
5
|
+
# Netscape Communications Corporation.
|
6
|
+
# Portions created by the Initial Developer are Copyright (C) 2001
|
7
|
+
# the Initial Developer. All Rights Reserved.
|
8
|
+
#
|
9
|
+
# Contributor(s):
|
10
|
+
# Jeff Hodges - port to Ruby
|
11
|
+
# Mark Pilgrim - port to Python
|
12
|
+
# Shy Shalom - original C code
|
13
|
+
# Proofpoint, Inc.
|
14
|
+
#
|
15
|
+
# This library is free software; you can redistribute it and/or
|
16
|
+
# modify it under the terms of the GNU Lesser General Public
|
17
|
+
# License as published by the Free Software Foundation; either
|
18
|
+
# version 2.1 of the License, or (at your option) any later version.
|
19
|
+
#
|
20
|
+
# This library is distributed in the hope that it will be useful,
|
21
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
22
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
23
|
+
# Lesser General Public License for more details.
|
24
|
+
#
|
25
|
+
# You should have received a copy of the GNU Lesser General Public
|
26
|
+
# License along with this library; if not, write to the Free Software
|
27
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
28
|
+
# 02110-1301 USA
|
29
|
+
######################### END LICENSE BLOCK #########################
|
30
|
+
|
31
|
+
module CharDet
|
32
|
+
class MBCSGroupProber < CharSetGroupProber
|
33
|
+
def initialize
|
34
|
+
super
|
35
|
+
@_mProbers = [ UTF8Prober.new,
|
36
|
+
SJISProber.new,
|
37
|
+
EUCJPProber.new,
|
38
|
+
GB2312Prober.new,
|
39
|
+
EUCKRProber.new,
|
40
|
+
Big5Prober.new,
|
41
|
+
EUCTWProber.new ]
|
42
|
+
reset()
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|