mms2r 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -232,8 +232,11 @@ class TestMms2rMedia < Test::Unit::TestCase
232
232
  assert_equal result, mms.transform_text(type, text)
233
233
 
234
234
  # testing the default config
235
- assert_equal ['text/plain', ''], mms.transform_text('text/plain', 'Sent from my iPhone')
236
235
  assert_equal ['text/plain', ''], mms.transform_text('text/plain', "Sent via BlackBerry from T-Mobile")
236
+ assert_equal ['text/plain', ''], mms.transform_text('text/plain', "Sent from my Verizon Wireless BlackBerry")
237
+ assert_equal ['text/plain', ''], mms.transform_text('text/plain', 'Sent from my iPhone')
238
+ assert_equal ['text/plain', ''], mms.transform_text('text/plain', 'Sent from my iPhone.')
239
+ assert_equal ['text/plain', ''], mms.transform_text('text/plain', " \n\nimage/jpeg")
237
240
 
238
241
  # has a bad regexp
239
242
  mms.expects(:config).once.returns({'transform' => {type => [['(hello)', 'world']]}})
@@ -306,6 +309,16 @@ class TestMms2rMedia < Test::Unit::TestCase
306
309
  assert_nil mms.send(:attachment, ['text'])
307
310
  end
308
311
 
312
+ def test_type_from_filename(filename)
313
+ mms = MMS2R::Media.new(stub_mail())
314
+ assert_equal 'image/jpeg', mms.send(:type_from_filename, "example.jpg")
315
+ end
316
+
317
+ def test_type_from_filename_should_be_nil(filename)
318
+ mms = MMS2R::Media.new(stub_mail())
319
+ assert_nil mms.send(:type_from_filename, "example.example")
320
+ end
321
+
309
322
  def test_attachment_should_return_duck_typed_file
310
323
  mms = MMS2R::Media.new(stub_mail())
311
324
  temp_big = temp_text_file("hello world")
@@ -403,6 +416,20 @@ class TestMms2rMedia < Test::Unit::TestCase
403
416
  assert_equal false, mms.ignore_media?(type, part)
404
417
  end
405
418
 
419
+ def test_filename
420
+ name = 'foo.txt'
421
+ mms = MMS2R::Media.new(stub_mail())
422
+ part = stub(:sub_header => name, :content_type => 'text/plain')
423
+ assert_equal 'foo.txt', mms.filename?(part)
424
+ end
425
+
426
+ def test_filename_when_file_extension_missing_part
427
+ name = 'foo'
428
+ mms = MMS2R::Media.new(stub_mail())
429
+ part = stub(:sub_header => name, :content_type => 'text/plain')
430
+ assert_equal 'foo.txt', mms.filename?(part)
431
+ end
432
+
406
433
  def test_ignore_media_by_filename_regexp
407
434
  name = 'foo.txt'
408
435
  regexp = '/foo\.txt/i'
@@ -517,6 +544,16 @@ class TestMms2rMedia < Test::Unit::TestCase
517
544
  mms.purge # have to call purge since a file is put to disk as side effect
518
545
  end
519
546
 
547
+ def test_process_media_for_application_octet_stream_when_image
548
+ name = 'fake.jpg'
549
+ mms = MMS2R::Media.new(stub_mail())
550
+ part = stub(:sub_header => name, :content_type => 'application/octet-stream', :body => "data")
551
+ result = mms.process_media(part)
552
+ assert_equal 'image/jpeg', result.first
553
+ assert_match /fake\.jpg$/, result.last
554
+ mms.purge # have to call purge since a file is put to disk as side effect
555
+ end
556
+
520
557
  def test_process_media_for_all_other_media
521
558
  name = 'foo.txt'
522
559
  mms = MMS2R::Media.new(stub_mail())
@@ -100,4 +100,17 @@ class TestMmsAttNet < Test::Unit::TestCase
100
100
  assert_not_nil mms.media['image/jpeg'].first
101
101
  assert_match(/Windows-1252\?B\?QkMtV0FLRS5qcGc/, mms.media['image/jpeg'].first)
102
102
  end
103
+
104
+ def test_image_from_blackberry2
105
+ mail = TMail::Mail.parse(load_mail('att-blackberry-02.mail').join)
106
+ mms = MMS2R::Media.new(mail)
107
+
108
+ assert_equal 2, mms.media.size
109
+
110
+ assert_not_nil mms.media['text/plain']
111
+ assert_match /^Testing memorymail from my blackberry and at&t.$/, IO.readlines(mms.media['text/plain'].first).join.strip
112
+
113
+ assert_not_nil mms.media['image/jpeg'].first
114
+ assert_match(/IMG00367.jpg/, mms.media['image/jpeg'].first)
115
+ end
103
116
  end
@@ -26,7 +26,7 @@ class TestMmsNetcomNo < Test::Unit::TestCase
26
26
  assert_equal 1, mms.media['text/plain'].size
27
27
  assert_not_nil mms.media['image/jpeg']
28
28
  assert_equal 1, mms.media['image/jpeg'].size
29
- assert_file_size mms.media['image/jpeg'].first, 28471
29
+ assert_file_size mms.media['image/jpeg'].first, 337
30
30
 
31
31
  mms.purge
32
32
  end
@@ -35,7 +35,7 @@ class TestMmsNetcomNo < Test::Unit::TestCase
35
35
  mail = TMail::Mail.parse(load_mail('netcom-image-01.mail').join)
36
36
  mms = MMS2R::Media.new(mail)
37
37
  file = mms.default_media
38
- assert_equal 28471, file.size
38
+ assert_equal 337, file.size
39
39
 
40
40
  mms.purge
41
41
  end
@@ -25,7 +25,7 @@ class TestMmsThreeCoUk < Test::Unit::TestCase
25
25
  assert_not_nil mms.media['image/jpeg']
26
26
  assert_equal 1, mms.media['image/jpeg'].size
27
27
  assert_match(/17102007.jpg$/, mms.media['image/jpeg'].first)
28
- assert_file_size mms.media['image/jpeg'].first, 29908
28
+ assert_file_size mms.media['image/jpeg'].first, 337
29
29
 
30
30
  mms.purge
31
31
  end
@@ -21,7 +21,7 @@ class TestMobileIndosatNetId < Test::Unit::TestCase
21
21
  assert_equal 1, mms.media['image/jpeg'].size
22
22
  assert_not_nil mms.media['image/jpeg'].first
23
23
  assert_match /Foto_14_.jpg/, mms.media['image/jpeg'].first
24
- assert_file_size(mms.media['image/jpeg'].first, 10022)
24
+ assert_file_size(mms.media['image/jpeg'].first, 337)
25
25
  assert_equal "Hello World", mms.default_text.read
26
26
  mms.purge
27
27
  end
@@ -46,7 +46,7 @@ class TestMobileIndosatNetId < Test::Unit::TestCase
46
46
  assert_equal 1, mms.media['image/jpeg'].size
47
47
  assert_not_nil mms.media['image/jpeg'].first
48
48
  assert_match /6033_small.jpeg/, mms.media['image/jpeg'].first
49
- assert_file_size(mms.media['image/jpeg'].first, 3684)
49
+ assert_file_size(mms.media['image/jpeg'].first, 337)
50
50
  mms.purge
51
51
  end
52
52
  end
@@ -21,7 +21,7 @@ class TestSmsSasktelCom < Test::Unit::TestCase
21
21
  assert_not_nil mms.media['image/jpeg']
22
22
  assert_equal 1, mms.media['image/jpeg'].size
23
23
  assert_match /A1.8463391017738573$/, mms.media['image/jpeg'].first
24
- assert_file_size(mms.media['image/jpeg'].first, 7336)
24
+ assert_file_size(mms.media['image/jpeg'].first, 337)
25
25
  mms.purge
26
26
  end
27
27
 
@@ -55,4 +55,16 @@ class TestTmobileNet < Test::Unit::TestCase
55
55
  assert_match(/Windows-1252\?B\?SU1HMDAyMzkuanBn/, mms.media['image/jpeg'].first)
56
56
  mms.purge
57
57
  end
58
+
59
+ def test_image_from_blackberry2
60
+ mail = TMail::Mail.parse(load_mail('tmobile-blackberry-02.mail').join)
61
+ mms = MMS2R::Media.new(mail)
62
+
63
+ assert_equal 1, mms.media.size
64
+ assert_nil mms.media['text/plain']
65
+
66
+ assert_not_nil mms.media['image/jpeg'].first
67
+ assert_match(/Windows-1252\?B\?SU1HMDAxNDEuanBn/, mms.media['image/jpeg'].first)
68
+ mms.purge
69
+ end
58
70
  end
@@ -46,6 +46,22 @@ class TestVzwpixCom < Test::Unit::TestCase
46
46
  mms.purge
47
47
  end
48
48
 
49
+ def test_simple_image_new_message_april_2008
50
+ # vzwpix.com service
51
+ mail = TMail::Mail.parse(load_mail('verizon-image-03.mail').join)
52
+ mms = MMS2R::Media.new(mail)
53
+
54
+ assert_equal 1, mms.media.size
55
+ assert_nil mms.media['text/plain']
56
+ assert_nil mms.media['text/html']
57
+ assert_not_nil mms.media['image/jpeg'][0]
58
+ assert_match(/0414082054.jpg$/, mms.media['image/jpeg'][0])
59
+
60
+ assert_file_size mms.media['image/jpeg'][0], 337
61
+
62
+ mms.purge
63
+ end
64
+
49
65
  def test_simple_text
50
66
  # vzwpix.com service
51
67
  mail = TMail::Mail.parse(load_mail('verizon-text-01.mail').join)
metadata CHANGED
@@ -1,36 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mms2r
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Mondragon
8
8
  autorequire:
9
9
  bindir: bin
10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3bqeEZwZj0o2HLxOHg0sSOc16rCfX5yvDo7bFM0XAMvwNgYg8ifQ
29
- zeHINowDygx2eefh0hynPGd/QwgANxHpr4+V93KLsyLosIgAIsqoXRkNx3a5gecL
30
- q8SfeAt4oNk4pWm9Ocmiww==
31
- -----END CERTIFICATE-----
10
+ cert_chain: []
32
11
 
33
- date: 2008-02-22 00:00:00 -08:00
12
+ date: 2008-04-15 00:00:00 -07:00
34
13
  default_executable:
35
14
  dependencies:
36
15
  - !ruby/object:Gem::Dependency
@@ -58,7 +37,7 @@ dependencies:
58
37
  requirements:
59
38
  - - ">="
60
39
  - !ruby/object:Gem::Version
61
- version: 1.5.0
40
+ version: 1.5.1
62
41
  version:
63
42
  description: "== DESCRIPTION: MMS2R is a library that decodes the parts of an MMS message to disk while stripping out advertising injected by the mobile carriers. MMS messages are multipart email and the carriers often inject branding into these messages. Use MMS2R if you want to get at the real user generated content from a MMS without having to deal with the cruft from the carriers. If MMS2R is not aware of a particular carrier no extra processing is done to the MMS other than decoding and consolidating its media. Contact the author to add additional carriers to be processed by the library. Suggestions and patches appreciated and welcomed! Corpus of carriers currently processed by MMS2R: * Alltel: message.alltel.com * AT&T/Cingular/Legacy: mms.att.net, txt.att.net, mmode.com, mms.mycingular.com, cingularme.com * Bell South / Suncom: bellsouth.net * Cricket Wireless: mms.mycricket.com * Dobson/Cellular One: mms.dobson.net * Helio: mms.myhelio.com * Hutchison 3G UK Ltd: mms.three.co.uk * INDOSAT M2: mobile.indosat.net.id * LUXGSM S.A.: mms.luxgsm.lu * NetCom (Norway): mms.netcom.no * Nextel: messaging.nextel.com * O2 Germany: mms.o2online.de * Orange & Regional Oranges: orangemms.net, mmsemail.orange.pl, orange.fr * PXT New Zealand: pxt.vodafone.net.nz * SaskTel: sms.sasktel.com * Sprint: pm.sprint.com, messaging.sprintpcs.com * T-Mobile: tmomail.net * Vodacom: mms.vodacom4me.co.za * Verizon: vzwpix.com, vtext.com"
64
43
  email: mikemondragon@gmail.com
@@ -102,9 +81,13 @@ files:
102
81
  - lib/mms2r/media.rb
103
82
  - lib/mms2r/media/sprint.rb
104
83
  - test/fixtures/alltel-image-01.mail
84
+ - test/fixtures/att-blackberry-02.mail
105
85
  - test/fixtures/att-blackberry.mail
106
86
  - test/fixtures/att-image-01.mail
107
87
  - test/fixtures/att-image-02.mail
88
+ - test/fixtures/att-iphone-01.mail
89
+ - test/fixtures/att-iphone-02.mail
90
+ - test/fixtures/att-iphone-03.mail
108
91
  - test/fixtures/att-text-01.mail
109
92
  - test/fixtures/cingularme-text-01.mail
110
93
  - test/fixtures/cingularme-text-02.mail
@@ -141,12 +124,14 @@ files:
141
124
  - test/fixtures/sprint.mov
142
125
  - test/fixtures/suncom-blackberry.mail
143
126
  - test/fixtures/three-uk-image-01.mail
127
+ - test/fixtures/tmobile-blackberry-02.mail
144
128
  - test/fixtures/tmobile-blackberry.mail
145
129
  - test/fixtures/tmobile-image-01.mail
146
130
  - test/fixtures/tmobile-image-02.mail
147
131
  - test/fixtures/verizon-blackberry.mail
148
132
  - test/fixtures/verizon-image-01.mail
149
133
  - test/fixtures/verizon-image-02.mail
134
+ - test/fixtures/verizon-image-03.mail
150
135
  - test/fixtures/verizon-text-01.mail
151
136
  - test/fixtures/verizon-video-01.mail
152
137
  - test/fixtures/vodacom4me-co-za-01.mail
@@ -201,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
186
  requirements: []
202
187
 
203
188
  rubyforge_project: mms2r
204
- rubygems_version: 1.0.1
189
+ rubygems_version: 1.1.1
205
190
  signing_key:
206
191
  specification_version: 2
207
192
  summary: Extract user media from MMS (and not carrier cruft)
data.tar.gz.sig DELETED
@@ -1,2 +0,0 @@
1
- ��!��<�/��7���f(<�27w <��(u�C,
2
- :�r/�
metadata.gz.sig DELETED
Binary file