otherinbox-mail 2.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. data/CHANGELOG.rdoc +607 -0
  2. data/CONTRIBUTING.md +45 -0
  3. data/Dependencies.txt +3 -0
  4. data/Gemfile +26 -0
  5. data/Gemfile.lock +44 -0
  6. data/README.md +663 -0
  7. data/Rakefile +40 -0
  8. data/TODO.rdoc +9 -0
  9. data/lib/VERSION +4 -0
  10. data/lib/mail.rb +101 -0
  11. data/lib/mail/attachments_list.rb +104 -0
  12. data/lib/mail/body.rb +291 -0
  13. data/lib/mail/configuration.rb +75 -0
  14. data/lib/mail/core_extensions/nil.rb +17 -0
  15. data/lib/mail/core_extensions/object.rb +13 -0
  16. data/lib/mail/core_extensions/shell_escape.rb +56 -0
  17. data/lib/mail/core_extensions/smtp.rb +25 -0
  18. data/lib/mail/core_extensions/string.rb +33 -0
  19. data/lib/mail/core_extensions/string/access.rb +145 -0
  20. data/lib/mail/core_extensions/string/multibyte.rb +78 -0
  21. data/lib/mail/elements.rb +14 -0
  22. data/lib/mail/elements/address.rb +306 -0
  23. data/lib/mail/elements/address_list.rb +74 -0
  24. data/lib/mail/elements/content_disposition_element.rb +30 -0
  25. data/lib/mail/elements/content_location_element.rb +25 -0
  26. data/lib/mail/elements/content_transfer_encoding_element.rb +24 -0
  27. data/lib/mail/elements/content_type_element.rb +35 -0
  28. data/lib/mail/elements/date_time_element.rb +26 -0
  29. data/lib/mail/elements/envelope_from_element.rb +34 -0
  30. data/lib/mail/elements/message_ids_element.rb +29 -0
  31. data/lib/mail/elements/mime_version_element.rb +26 -0
  32. data/lib/mail/elements/phrase_list.rb +21 -0
  33. data/lib/mail/elements/received_element.rb +30 -0
  34. data/lib/mail/encodings.rb +274 -0
  35. data/lib/mail/encodings/7bit.rb +31 -0
  36. data/lib/mail/encodings/8bit.rb +31 -0
  37. data/lib/mail/encodings/base64.rb +33 -0
  38. data/lib/mail/encodings/binary.rb +31 -0
  39. data/lib/mail/encodings/quoted_printable.rb +38 -0
  40. data/lib/mail/encodings/transfer_encoding.rb +58 -0
  41. data/lib/mail/envelope.rb +35 -0
  42. data/lib/mail/field.rb +234 -0
  43. data/lib/mail/field_list.rb +33 -0
  44. data/lib/mail/fields.rb +35 -0
  45. data/lib/mail/fields/bcc_field.rb +56 -0
  46. data/lib/mail/fields/cc_field.rb +55 -0
  47. data/lib/mail/fields/comments_field.rb +41 -0
  48. data/lib/mail/fields/common/address_container.rb +16 -0
  49. data/lib/mail/fields/common/common_address.rb +125 -0
  50. data/lib/mail/fields/common/common_date.rb +42 -0
  51. data/lib/mail/fields/common/common_field.rb +51 -0
  52. data/lib/mail/fields/common/common_message_id.rb +44 -0
  53. data/lib/mail/fields/common/parameter_hash.rb +58 -0
  54. data/lib/mail/fields/content_description_field.rb +19 -0
  55. data/lib/mail/fields/content_disposition_field.rb +69 -0
  56. data/lib/mail/fields/content_id_field.rb +63 -0
  57. data/lib/mail/fields/content_location_field.rb +42 -0
  58. data/lib/mail/fields/content_transfer_encoding_field.rb +50 -0
  59. data/lib/mail/fields/content_type_field.rb +198 -0
  60. data/lib/mail/fields/date_field.rb +57 -0
  61. data/lib/mail/fields/from_field.rb +55 -0
  62. data/lib/mail/fields/in_reply_to_field.rb +55 -0
  63. data/lib/mail/fields/keywords_field.rb +44 -0
  64. data/lib/mail/fields/message_id_field.rb +83 -0
  65. data/lib/mail/fields/mime_version_field.rb +53 -0
  66. data/lib/mail/fields/optional_field.rb +13 -0
  67. data/lib/mail/fields/received_field.rb +75 -0
  68. data/lib/mail/fields/references_field.rb +55 -0
  69. data/lib/mail/fields/reply_to_field.rb +55 -0
  70. data/lib/mail/fields/resent_bcc_field.rb +55 -0
  71. data/lib/mail/fields/resent_cc_field.rb +55 -0
  72. data/lib/mail/fields/resent_date_field.rb +35 -0
  73. data/lib/mail/fields/resent_from_field.rb +55 -0
  74. data/lib/mail/fields/resent_message_id_field.rb +34 -0
  75. data/lib/mail/fields/resent_sender_field.rb +62 -0
  76. data/lib/mail/fields/resent_to_field.rb +55 -0
  77. data/lib/mail/fields/return_path_field.rb +65 -0
  78. data/lib/mail/fields/sender_field.rb +67 -0
  79. data/lib/mail/fields/structured_field.rb +51 -0
  80. data/lib/mail/fields/subject_field.rb +16 -0
  81. data/lib/mail/fields/to_field.rb +55 -0
  82. data/lib/mail/fields/unstructured_field.rb +191 -0
  83. data/lib/mail/header.rb +265 -0
  84. data/lib/mail/indifferent_hash.rb +146 -0
  85. data/lib/mail/mail.rb +255 -0
  86. data/lib/mail/matchers/has_sent_mail.rb +124 -0
  87. data/lib/mail/message.rb +2059 -0
  88. data/lib/mail/multibyte.rb +42 -0
  89. data/lib/mail/multibyte/chars.rb +474 -0
  90. data/lib/mail/multibyte/exceptions.rb +8 -0
  91. data/lib/mail/multibyte/unicode.rb +392 -0
  92. data/lib/mail/multibyte/utils.rb +60 -0
  93. data/lib/mail/network.rb +14 -0
  94. data/lib/mail/network/delivery_methods/exim.rb +53 -0
  95. data/lib/mail/network/delivery_methods/file_delivery.rb +40 -0
  96. data/lib/mail/network/delivery_methods/sendmail.rb +62 -0
  97. data/lib/mail/network/delivery_methods/smtp.rb +153 -0
  98. data/lib/mail/network/delivery_methods/smtp_connection.rb +74 -0
  99. data/lib/mail/network/delivery_methods/test_mailer.rb +40 -0
  100. data/lib/mail/network/retriever_methods/base.rb +63 -0
  101. data/lib/mail/network/retriever_methods/imap.rb +168 -0
  102. data/lib/mail/network/retriever_methods/pop3.rb +140 -0
  103. data/lib/mail/network/retriever_methods/test_retriever.rb +47 -0
  104. data/lib/mail/parsers/address_lists.rb +64 -0
  105. data/lib/mail/parsers/address_lists.treetop +19 -0
  106. data/lib/mail/parsers/content_disposition.rb +535 -0
  107. data/lib/mail/parsers/content_disposition.treetop +46 -0
  108. data/lib/mail/parsers/content_location.rb +139 -0
  109. data/lib/mail/parsers/content_location.treetop +20 -0
  110. data/lib/mail/parsers/content_transfer_encoding.rb +162 -0
  111. data/lib/mail/parsers/content_transfer_encoding.treetop +20 -0
  112. data/lib/mail/parsers/content_type.rb +967 -0
  113. data/lib/mail/parsers/content_type.treetop +68 -0
  114. data/lib/mail/parsers/date_time.rb +114 -0
  115. data/lib/mail/parsers/date_time.treetop +11 -0
  116. data/lib/mail/parsers/envelope_from.rb +194 -0
  117. data/lib/mail/parsers/envelope_from.treetop +32 -0
  118. data/lib/mail/parsers/message_ids.rb +45 -0
  119. data/lib/mail/parsers/message_ids.treetop +15 -0
  120. data/lib/mail/parsers/mime_version.rb +144 -0
  121. data/lib/mail/parsers/mime_version.treetop +19 -0
  122. data/lib/mail/parsers/phrase_lists.rb +45 -0
  123. data/lib/mail/parsers/phrase_lists.treetop +15 -0
  124. data/lib/mail/parsers/received.rb +71 -0
  125. data/lib/mail/parsers/received.treetop +11 -0
  126. data/lib/mail/parsers/rfc2045.rb +464 -0
  127. data/lib/mail/parsers/rfc2045.treetop +36 -0
  128. data/lib/mail/parsers/rfc2822.rb +5341 -0
  129. data/lib/mail/parsers/rfc2822.treetop +410 -0
  130. data/lib/mail/parsers/rfc2822_obsolete.rb +3768 -0
  131. data/lib/mail/parsers/rfc2822_obsolete.treetop +241 -0
  132. data/lib/mail/part.rb +116 -0
  133. data/lib/mail/parts_list.rb +55 -0
  134. data/lib/mail/patterns.rb +34 -0
  135. data/lib/mail/utilities.rb +215 -0
  136. data/lib/mail/version.rb +24 -0
  137. data/lib/mail/version_specific/ruby_1_8.rb +98 -0
  138. data/lib/mail/version_specific/ruby_1_9.rb +113 -0
  139. data/lib/tasks/corpus.rake +125 -0
  140. data/lib/tasks/treetop.rake +10 -0
  141. metadata +253 -0
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+ require 'mail/encodings/8bit'
3
+
4
+ module Mail
5
+ module Encodings
6
+ class SevenBit < EightBit
7
+ NAME = '7bit'
8
+
9
+ PRIORITY = 1
10
+
11
+ # 7bit and 8bit operate the same
12
+
13
+ # Decode the string
14
+ def self.decode(str)
15
+ super
16
+ end
17
+
18
+ # Encode the string
19
+ def self.encode(str)
20
+ super
21
+ end
22
+
23
+ # Idenity encodings have a fixed cost, 1 byte out per 1 byte in
24
+ def self.cost(str)
25
+ super
26
+ end
27
+
28
+ Encodings.register(NAME, self)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+ require 'mail/encodings/binary'
3
+
4
+ module Mail
5
+ module Encodings
6
+ class EightBit < Binary
7
+ NAME = '8bit'
8
+
9
+ PRIORITY = 4
10
+
11
+ # 8bit is an identiy encoding, meaning nothing to do
12
+
13
+ # Decode the string
14
+ def self.decode(str)
15
+ str.to_lf
16
+ end
17
+
18
+ # Encode the string
19
+ def self.encode(str)
20
+ str.to_crlf
21
+ end
22
+
23
+ # Idenity encodings have a fixed cost, 1 byte out per 1 byte in
24
+ def self.cost(str)
25
+ 1.0
26
+ end
27
+
28
+ Encodings.register(NAME, self)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,33 @@
1
+ # encoding: utf-8
2
+ require 'mail/encodings/7bit'
3
+
4
+ module Mail
5
+ module Encodings
6
+ class Base64 < SevenBit
7
+ NAME = 'base64'
8
+
9
+ PRIORITY = 3
10
+
11
+ def self.can_encode?(enc)
12
+ true
13
+ end
14
+
15
+ # Decode the string from Base64
16
+ def self.decode(str)
17
+ RubyVer.decode_base64( str )
18
+ end
19
+
20
+ # Encode the string to Base64
21
+ def self.encode(str)
22
+ RubyVer.encode_base64( str ).to_crlf
23
+ end
24
+
25
+ # Base64 has a fixed cost, 4 bytes out per 3 bytes in
26
+ def self.cost(str)
27
+ 4.0/3
28
+ end
29
+
30
+ Encodings.register(NAME, self)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+ require 'mail/encodings/transfer_encoding'
3
+
4
+ module Mail
5
+ module Encodings
6
+ class Binary < TransferEncoding
7
+ NAME = 'binary'
8
+
9
+ PRIORITY = 5
10
+
11
+ # Binary is an identiy encoding, meaning nothing to do
12
+
13
+ # Decode the string
14
+ def self.decode(str)
15
+ str
16
+ end
17
+
18
+ # Encode the string
19
+ def self.encode(str)
20
+ str
21
+ end
22
+
23
+ # Idenity encodings have a fixed cost, 1 byte out per 1 byte in
24
+ def self.cost(str)
25
+ 1.0
26
+ end
27
+
28
+ Encodings.register(NAME, self)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,38 @@
1
+ # encoding: utf-8
2
+ require 'mail/encodings/7bit'
3
+
4
+ module Mail
5
+ module Encodings
6
+ class QuotedPrintable < SevenBit
7
+ NAME='quoted-printable'
8
+
9
+ PRIORITY = 2
10
+
11
+ def self.can_encode?(str)
12
+ EightBit.can_encode? str
13
+ end
14
+
15
+ # Decode the string from Quoted-Printable
16
+ def self.decode(str)
17
+ str.unpack("M*").first
18
+ end
19
+
20
+ def self.encode(str)
21
+ [str].pack("M").gsub(/\n/, "\r\n")
22
+ end
23
+
24
+ def self.cost(str)
25
+ # These bytes probably do not need encoding
26
+ c = str.count("\x9\xA\xD\x20-\x3C\x3E-\x7E")
27
+ # Everything else turns into =XX where XX is a
28
+ # two digit hex number (taking 3 bytes)
29
+ total = (str.bytesize - c)*3 + c
30
+ total.to_f/str.bytesize
31
+ end
32
+
33
+ private
34
+
35
+ Encodings.register(NAME, self)
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,58 @@
1
+ # encoding: utf-8
2
+ module Mail
3
+ module Encodings
4
+ class TransferEncoding
5
+ NAME = ''
6
+
7
+ PRIORITY = -1
8
+
9
+ def self.can_transport?(enc)
10
+ enc = Encodings.get_name(enc)
11
+ if Encodings.defined? enc
12
+ Encodings.get_encoding(enc).new.is_a? self
13
+ else
14
+ false
15
+ end
16
+ end
17
+
18
+ def self.can_encode?(enc)
19
+ can_transport? enc
20
+ end
21
+
22
+ def self.cost(str)
23
+ raise "Unimplemented"
24
+ end
25
+
26
+ def self.to_s
27
+ self::NAME
28
+ end
29
+
30
+ def self.get_best_compatible(source_encoding, str)
31
+ if self.can_transport? source_encoding then
32
+ source_encoding
33
+ else
34
+ choices = []
35
+ Encodings.get_all.each do |enc|
36
+ choices << enc if self.can_transport? enc and enc.can_encode? source_encoding
37
+ end
38
+ best = nil
39
+ best_cost = 100
40
+ choices.each do |enc|
41
+ this_cost = enc.cost str
42
+ if this_cost < best_cost then
43
+ best_cost = this_cost
44
+ best = enc
45
+ elsif this_cost == best_cost then
46
+ best = enc if enc::PRIORITY < best::PRIORITY
47
+ end
48
+ end
49
+ best
50
+ end
51
+ end
52
+
53
+ def to_s
54
+ self.class.to_s
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ #
3
+ # = Mail Envelope
4
+ #
5
+ # The Envelope class provides a field for the first line in an
6
+ # mbox file, that looks like "From mikel@test.lindsaar.net DATETIME"
7
+ #
8
+ # This envelope class reads that line, and turns it into an
9
+ # Envelope.from and Envelope.date for your use.
10
+ module Mail
11
+ class Envelope < StructuredField
12
+
13
+ def initialize(*args)
14
+ super(FIELD_NAME, strip_field(FIELD_NAME, args.last))
15
+ end
16
+
17
+ def tree
18
+ @element ||= Mail::EnvelopeFromElement.new(value)
19
+ @tree ||= @element.tree
20
+ end
21
+
22
+ def element
23
+ @element ||= Mail::EnvelopeFromElement.new(value)
24
+ end
25
+
26
+ def date
27
+ ::DateTime.parse("#{element.date_time}")
28
+ end
29
+
30
+ def from
31
+ element.address
32
+ end
33
+
34
+ end
35
+ end
data/lib/mail/field.rb ADDED
@@ -0,0 +1,234 @@
1
+ require 'mail/fields'
2
+
3
+ # encoding: utf-8
4
+ module Mail
5
+ # Provides a single class to call to create a new structured or unstructured
6
+ # field. Works out per RFC what field of field it is being given and returns
7
+ # the correct field of class back on new.
8
+ #
9
+ # ===Per RFC 2822
10
+ #
11
+ # 2.2. Header Fields
12
+ #
13
+ # Header fields are lines composed of a field name, followed by a colon
14
+ # (":"), followed by a field body, and terminated by CRLF. A field
15
+ # name MUST be composed of printable US-ASCII characters (i.e.,
16
+ # characters that have values between 33 and 126, inclusive), except
17
+ # colon. A field body may be composed of any US-ASCII characters,
18
+ # except for CR and LF. However, a field body may contain CRLF when
19
+ # used in header "folding" and "unfolding" as described in section
20
+ # 2.2.3. All field bodies MUST conform to the syntax described in
21
+ # sections 3 and 4 of this standard.
22
+ #
23
+ class Field
24
+
25
+ include Patterns
26
+ include Comparable
27
+
28
+ STRUCTURED_FIELDS = %w[ bcc cc content-description content-disposition
29
+ content-id content-location content-transfer-encoding
30
+ content-type date from in-reply-to keywords message-id
31
+ mime-version received references reply-to
32
+ resent-bcc resent-cc resent-date resent-from
33
+ resent-message-id resent-sender resent-to
34
+ return-path sender to ]
35
+
36
+ KNOWN_FIELDS = STRUCTURED_FIELDS + ['comments', 'subject']
37
+
38
+ # Generic Field Exception
39
+ class FieldError < StandardError
40
+ end
41
+
42
+ # Raised when a parsing error has occurred (ie, a StructuredField has tried
43
+ # to parse a field that is invalid or improperly written)
44
+ class ParseError < FieldError #:nodoc:
45
+ attr_accessor :element, :value, :reason
46
+
47
+ def initialize(element, value, reason)
48
+ @element = element
49
+ @value = value
50
+ @reason = reason
51
+ super("#{element} can not parse |#{value}|\nReason was: #{reason}")
52
+ end
53
+ end
54
+
55
+ # Raised when attempting to set a structured field's contents to an invalid syntax
56
+ class SyntaxError < FieldError #:nodoc:
57
+ end
58
+
59
+ # Accepts a string:
60
+ #
61
+ # Field.new("field-name: field data")
62
+ #
63
+ # Or name, value pair:
64
+ #
65
+ # Field.new("field-name", "value")
66
+ #
67
+ # Or a name by itself:
68
+ #
69
+ # Field.new("field-name")
70
+ #
71
+ # Note, does not want a terminating carriage return. Returns
72
+ # self appropriately parsed. If value is not a string, then
73
+ # it will be passed through as is, for example, content-type
74
+ # field can accept an array with the type and a hash of
75
+ # parameters:
76
+ #
77
+ # Field.new('content-type', ['text', 'plain', {:charset => 'UTF-8'}])
78
+ def initialize(name, value = nil, charset = 'utf-8')
79
+ case
80
+ when name =~ /:/ # Field.new("field-name: field data")
81
+ charset = value unless value.blank?
82
+ name, value = split(name)
83
+ create_field(name, value, charset)
84
+ when name !~ /:/ && value.blank? # Field.new("field-name")
85
+ create_field(name, nil, charset)
86
+ else # Field.new("field-name", "value")
87
+ create_field(name, value, charset)
88
+ end
89
+ return self
90
+ end
91
+
92
+ def field=(value)
93
+ @field = value
94
+ end
95
+
96
+ def field
97
+ @field
98
+ end
99
+
100
+ def name
101
+ field.name
102
+ end
103
+
104
+ def value
105
+ field.value
106
+ end
107
+
108
+ def value=(val)
109
+ create_field(name, val, charset)
110
+ end
111
+
112
+ def to_s
113
+ field.to_s
114
+ end
115
+
116
+ def update(name, value)
117
+ create_field(name, value, charset)
118
+ end
119
+
120
+ def same( other )
121
+ match_to_s(other.name, field.name)
122
+ end
123
+
124
+ alias_method :==, :same
125
+
126
+ def <=>( other )
127
+ self_order = FIELD_ORDER.rindex(self.name.to_s.downcase) || 100
128
+ other_order = FIELD_ORDER.rindex(other.name.to_s.downcase) || 100
129
+ self_order <=> other_order
130
+ end
131
+
132
+ def method_missing(name, *args, &block)
133
+ field.send(name, *args, &block)
134
+ end
135
+
136
+ FIELD_ORDER = %w[ return-path received
137
+ resent-date resent-from resent-sender resent-to
138
+ resent-cc resent-bcc resent-message-id
139
+ date from sender reply-to to cc bcc
140
+ message-id in-reply-to references
141
+ subject comments keywords
142
+ mime-version content-type content-transfer-encoding
143
+ content-location content-disposition content-description ]
144
+
145
+ private
146
+
147
+ def split(raw_field)
148
+ match_data = raw_field.mb_chars.match(/^(#{FIELD_NAME})\s*:\s*(#{FIELD_BODY})?$/)
149
+ [match_data[1].to_s.mb_chars.strip, match_data[2].to_s.mb_chars.strip]
150
+ rescue
151
+ STDERR.puts "WARNING: Could not parse (and so ignorning) '#{raw_field}'"
152
+ end
153
+
154
+ def create_field(name, value, charset)
155
+ begin
156
+ self.field = new_field(name, value, charset)
157
+ rescue Mail::Field::ParseError => e
158
+ self.field = Mail::UnstructuredField.new(name, value)
159
+ self.field.errors << [name, value, e]
160
+ self.field
161
+ end
162
+ end
163
+
164
+ def new_field(name, value, charset)
165
+ # Could do this with constantize and make it "as DRY as", but a simple case
166
+ # statement is, well, simpler...
167
+ case name.to_s.downcase
168
+ when /^to$/i
169
+ ToField.new(value, charset)
170
+ when /^cc$/i
171
+ CcField.new(value, charset)
172
+ when /^bcc$/i
173
+ BccField.new(value, charset)
174
+ when /^message-id$/i
175
+ MessageIdField.new(value, charset)
176
+ when /^in-reply-to$/i
177
+ InReplyToField.new(value, charset)
178
+ when /^references$/i
179
+ ReferencesField.new(value, charset)
180
+ when /^subject$/i
181
+ SubjectField.new(value, charset)
182
+ when /^comments$/i
183
+ CommentsField.new(value, charset)
184
+ when /^keywords$/i
185
+ KeywordsField.new(value, charset)
186
+ when /^date$/i
187
+ DateField.new(value, charset)
188
+ when /^from$/i
189
+ FromField.new(value, charset)
190
+ when /^sender$/i
191
+ SenderField.new(value, charset)
192
+ when /^reply-to$/i
193
+ ReplyToField.new(value, charset)
194
+ when /^resent-date$/i
195
+ ResentDateField.new(value, charset)
196
+ when /^resent-from$/i
197
+ ResentFromField.new(value, charset)
198
+ when /^resent-sender$/i
199
+ ResentSenderField.new(value, charset)
200
+ when /^resent-to$/i
201
+ ResentToField.new(value, charset)
202
+ when /^resent-cc$/i
203
+ ResentCcField.new(value, charset)
204
+ when /^resent-bcc$/i
205
+ ResentBccField.new(value, charset)
206
+ when /^resent-message-id$/i
207
+ ResentMessageIdField.new(value, charset)
208
+ when /^return-path$/i
209
+ ReturnPathField.new(value, charset)
210
+ when /^received$/i
211
+ ReceivedField.new(value, charset)
212
+ when /^mime-version$/i
213
+ MimeVersionField.new(value, charset)
214
+ when /^content-transfer-encoding$/i
215
+ ContentTransferEncodingField.new(value, charset)
216
+ when /^content-description$/i
217
+ ContentDescriptionField.new(value, charset)
218
+ when /^content-disposition$/i
219
+ ContentDispositionField.new(value, charset)
220
+ when /^content-type$/i
221
+ ContentTypeField.new(value, charset)
222
+ when /^content-id$/i
223
+ ContentIdField.new(value, charset)
224
+ when /^content-location$/i
225
+ ContentLocationField.new(value, charset)
226
+ else
227
+ OptionalField.new(name, value, charset)
228
+ end
229
+
230
+ end
231
+
232
+ end
233
+
234
+ end