pony-express 0.6.6 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/ext/mimetic.cxx +19 -17
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.7
|
data/ext/mimetic.cxx
CHANGED
@@ -16,6 +16,8 @@ extern "C" {
|
|
16
16
|
#define RUBY_ENCODING(str) string(rb_enc_get(str)->name)
|
17
17
|
#define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f)
|
18
18
|
#define FORCE_ENCODING(str,enc) rb_enc_associate(str, rb_to_encoding(enc)); ENC_CODERANGE_CLEAR(str);
|
19
|
+
#define TO_S(v) rb_funcall(v, rb_intern("to_s"), 0)
|
20
|
+
#define CSTRING(v) RSTRING_PTR(TYPE(v) != T_STRING ? TO_S(v) : v)
|
19
21
|
|
20
22
|
static VALUE rb_mMimetic;
|
21
23
|
static VALUE eRuntimeError;
|
@@ -87,10 +89,10 @@ string safe_rfc2047(string v) {
|
|
87
89
|
}
|
88
90
|
|
89
91
|
string quoted_printable(VALUE str) {
|
90
|
-
VALUE ascii = rb_str_new2(
|
92
|
+
VALUE ascii = rb_str_new2(CSTRING(str));
|
91
93
|
FORCE_ENCODING(ascii, rb_ASCII);
|
92
94
|
if (rb_str_cmp(ascii, str) != 0) {
|
93
|
-
string raw =
|
95
|
+
string raw = CSTRING(str);
|
94
96
|
QP::Encoder qp;
|
95
97
|
istringstream is(raw);
|
96
98
|
ostringstream encoded;
|
@@ -100,7 +102,7 @@ string quoted_printable(VALUE str) {
|
|
100
102
|
return "=?" + RUBY_ENCODING(str) + "?Q?" + safe_rfc2047(encoded.str()) + "?=";
|
101
103
|
}
|
102
104
|
else {
|
103
|
-
return string(
|
105
|
+
return string(CSTRING(str));
|
104
106
|
}
|
105
107
|
}
|
106
108
|
|
@@ -111,7 +113,7 @@ void rb_load_mime_types(VALUE self, VALUE filename) {
|
|
111
113
|
char buffer[4096];
|
112
114
|
vector<string> data;
|
113
115
|
RE regex("(.+?)(?:[\\r\\n\\t]+|$)");
|
114
|
-
ifstream file(
|
116
|
+
ifstream file(CSTRING(filename), ios::in);
|
115
117
|
if (file.is_open()) {
|
116
118
|
while (!file.eof()) {
|
117
119
|
file.getline(buffer, 4096);
|
@@ -180,17 +182,17 @@ VALUE rb_mimetic_build(VALUE self, VALUE options) {
|
|
180
182
|
message->body().parts().push_back(html_part);
|
181
183
|
text_part->header().contentType("text/plain; charset=" + RUBY_ENCODING(text));
|
182
184
|
text_part->header().contentTransferEncoding("8bit");
|
183
|
-
text_part->header().contentId(tcid == Qnil ? content_id() + ">" : ContentId(
|
185
|
+
text_part->header().contentId(tcid == Qnil ? content_id() + ">" : ContentId(CSTRING(tcid)));
|
184
186
|
text_part->header().mimeVersion(v1);
|
185
|
-
text_part->body().assign(
|
187
|
+
text_part->body().assign(CSTRING(text));
|
186
188
|
html_part->header().contentType("text/html; charset=" + RUBY_ENCODING(html));
|
187
189
|
html_part->header().contentTransferEncoding("7bit");
|
188
|
-
html_part->header().contentId(hcid == Qnil ? content_id() + ">" : ContentId(
|
190
|
+
html_part->header().contentId(hcid == Qnil ? content_id() + ">" : ContentId(CSTRING(hcid)));
|
189
191
|
html_part->header().mimeVersion(v1);
|
190
|
-
html_part->body().assign(
|
192
|
+
html_part->body().assign(CSTRING(html));
|
191
193
|
}
|
192
194
|
else {
|
193
|
-
message->body().assign(
|
195
|
+
message->body().assign(CSTRING(text));
|
194
196
|
message->header().contentType("text/plain; charset=" + RUBY_ENCODING(text));
|
195
197
|
message->header().contentTransferEncoding("8bit");
|
196
198
|
message->header().mimeVersion(v1);
|
@@ -204,18 +206,18 @@ VALUE rb_mimetic_build(VALUE self, VALUE options) {
|
|
204
206
|
for (long i = 0; i < RARRAY_LEN(files); i++) {
|
205
207
|
attachment = rb_ary_entry(files, i);
|
206
208
|
if (attachment != Qnil && TYPE(attachment) == T_STRING)
|
207
|
-
mimetic_attach_file(message,
|
209
|
+
mimetic_attach_file(message, CSTRING(attachment));
|
208
210
|
}
|
209
211
|
}
|
210
212
|
|
211
|
-
message->header().from(
|
212
|
-
message->header().to(
|
213
|
+
message->header().from(CSTRING(from));
|
214
|
+
message->header().to(CSTRING(to));
|
213
215
|
message->header().subject(quoted_printable(subject));
|
214
|
-
message->header().messageid(mid != Qnil ?
|
216
|
+
message->header().messageid(mid != Qnil ? CSTRING(mid) : message_id(1));
|
215
217
|
|
216
|
-
if (replyto != Qnil) message->header().replyto(
|
217
|
-
if (cc != Qnil) message->header().cc(
|
218
|
-
if (bcc != Qnil) message->header().bcc(
|
218
|
+
if (replyto != Qnil) message->header().replyto(CSTRING(replyto));
|
219
|
+
if (cc != Qnil) message->header().cc(CSTRING(cc));
|
220
|
+
if (bcc != Qnil) message->header().bcc(CSTRING(bcc));
|
219
221
|
|
220
222
|
output << *message << endl;
|
221
223
|
delete message;
|
@@ -230,7 +232,7 @@ VALUE rb_mimetic_build(VALUE self, VALUE options) {
|
|
230
232
|
errors = rb_str_new2("Unknown Error");
|
231
233
|
}
|
232
234
|
|
233
|
-
rb_raise(eRuntimeError, "Mimetic boo boo : %s\n",
|
235
|
+
rb_raise(eRuntimeError, "Mimetic boo boo : %s\n", CSTRING(errors));
|
234
236
|
}
|
235
237
|
|
236
238
|
extern "C" {
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pony-express
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 7
|
10
|
+
version: 0.6.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Bharanee Rathna
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-10-06 00:00:00 +11:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|