mms2r 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,16 @@
1
+ == 1.0.5 / 2007-04-10 (William Murderface)
2
+
3
+ * patch submitted by Luke Francl
4
+ * made ignore_media? start its text check from the start of the file (Luke)
5
+ * added new text transform for Verizon messages (Luke)
6
+ * updated Nextel ignore conf (Luke)
7
+ * added addtional samples and tests for T-Mobile & Verizon (Luke)
8
+ * cleaned up MMS2R::Media documentation
9
+ * added Sprint broken image test for when media goes stale on their content server
10
+ * fixed teardown typo in lots of plases
11
+ * added tests for 4 three samples of unique variants of Sprint/Nextel text
12
+ * 100% test coverage!
13
+
1
14
  == 1.0.4 / 2007-04-09 (Metalocalypse)
2
15
 
3
16
  * fix teardown in test_mms2r_sprint.rb (shanesbrain.net)
data/Manifest.txt CHANGED
@@ -7,6 +7,7 @@ conf/mms2r_nextelmedia_ignore.yml
7
7
  conf/mms2r_sprintmedia_ignore.yml
8
8
  conf/mms2r_tmobilemedia_ignore.yml
9
9
  conf/mms2r_verizonmedia_ignore.yml
10
+ conf/mms2r_verizonmedia_transform.yml
10
11
  lib/mms2r.rb
11
12
  lib/mms2r/cingular_media.rb
12
13
  lib/mms2r/media.rb
@@ -47,14 +48,20 @@ test/files/hello_world_mail_plain_no_content_type.mail
47
48
  test/files/hello_world_mail_plain_with_content_type.mail
48
49
  test/files/mmode-image-01.mail
49
50
  test/files/nextel-image-01.mail
51
+ test/files/nextel-image-02.mail
52
+ test/files/nextel-image-03.mail
53
+ test/files/nextel-image-04.mail
50
54
  test/files/simple_image.mail
51
55
  test/files/simple_multipart_alternative.mail
52
56
  test/files/sprint-image-01.mail
57
+ test/files/sprint-image-02.mail
53
58
  test/files/sprint-text-01.mail
54
59
  test/files/sprint-video-01.mail
55
60
  test/files/sprint.mov
56
61
  test/files/tmobile-image-01.mail
62
+ test/files/tmobile-image-02.mail
57
63
  test/files/verizon-image-01.mail
64
+ test/files/verizon-image-02.mail
58
65
  test/files/verizon-text-01.mail
59
66
  test/files/verizon-video-01.mail
60
67
  test/files/vtext-text-01.mail
data/README.txt CHANGED
@@ -13,7 +13,8 @@ having to deal with the garbage from the carriers.
13
13
  If MMS2R is not aware of a particular carrier no extra processing is done
14
14
  to the MMS other than decoding and consolidating its media.
15
15
 
16
- Contact the author to add additional carriers to be processed by the library.
16
+ Contact the author to add additional carriers to be processed by the
17
+ library. Suggestions and patches appreciated and welcomed!
17
18
 
18
19
  Corpus of carriers currently processed by MMS2R:
19
20
 
@@ -43,12 +44,13 @@ TMail from 1.3.1 of ActionMailer is shipped as a vendor library with MMS2R
43
44
  mms = MMS2R::Media.create(media,Logger.new(STDOUT))
44
45
 
45
46
  # process finds all the media in a MMS, strips advertsing, then
46
- # writes the user generated media to disk
47
+ # writes the user generated media to disk in a temporary subdirectory
47
48
  mms.process
48
49
 
49
50
  # mms.media is a hash that is indexed by mime-type.
50
51
  # The mime-type key returns an array of filepaths
51
- # to media in the MMS that is of that type
52
+ # to media that were extract from the MMS and
53
+ # are of that type
52
54
  mms.media['image/jpeg'].each {|f| puts "#{f}"}
53
55
  mms.media['text/plain'].each {|f| puts "#{f}"}
54
56
 
@@ -61,7 +63,7 @@ TMail from 1.3.1 of ActionMailer is shipped as a vendor library with MMS2R
61
63
 
62
64
  puts "does the MMS have video? #{!mms.media['video/quicktime'].nil?}"
63
65
 
64
- #remove the media that was put to temporary disk
66
+ #remove all the media that was put to temporary disk
65
67
  mms.purge
66
68
 
67
69
  == REQUIREMENTS:
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ Hoe.new('mms2r', MMS2R::Media::VERSION) do |p|
15
15
  p.summary = 'Extract media from MMS'
16
16
  p.description = p.paragraphs_of('README.txt', 2..6).join("\n\n")
17
17
  p.url = p.paragraphs_of('README.txt', 1).first.strip
18
- p.changes = p.paragraphs_of('History.txt', 1).join("\n\n")
18
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
19
19
  p.extra_deps << ['hpricot']
20
20
  p.clean_globs << 'coverage'
21
21
  end
@@ -1,5 +1,10 @@
1
1
  ---
2
2
  text/plain:
3
3
  - This is an MMS message. 2006 Sprint Nextel. All rights reserved.
4
+ - This is an MMS message. Please go to
5
+ - This is a multi-part message in MIME format.
4
6
  text/html:
5
- - This is an MMS message. <br><center> 2006 Sprint Nextel. All rights reserved</center>
7
+ - "<html><body>\n\n<center>This is an MMS message. <br><center> 2006 Sprint Nextel. All rights reserved</center>"
8
+ - "<html><body>\n\nThis is an MMS message. <br><center> 2006 Sprint Nextel. All rights reserved</center>\n</body></html>"
9
+ - "<html><body>\n\nThis is an MMS message. <br><center> 2006 Sprint Nextel. All rights reserved <br></center>\n</body></html>"
10
+ - "<html><body>\n\nThis is an MMS message. Please go to "
@@ -0,0 +1,3 @@
1
+ ---
2
+ text/plain:
3
+ "(.*?)\n\nThis message was sent using PIX-FLIX Messaging service from Verizon Wireless!.*" : "\1"
data/lib/mms2r/media.rb CHANGED
@@ -171,7 +171,7 @@ module MMS2R
171
171
  m = /^([^\/]+)\//.match(type)[1]
172
172
  a.each do |i|
173
173
  if m.eql?('text')
174
- return true if part.body =~ /#{Regexp.escape("#{i}")}/m
174
+ return true if 0 == (part.body =~ /#{Regexp.escape("#{i}")}/m)
175
175
  else
176
176
  return true if filename?(part).eql?(i)
177
177
  end
@@ -195,9 +195,8 @@ module MMS2R
195
195
  end
196
196
 
197
197
  ##
198
- # Purges the unique directory created for this producer and
199
- # all of the media that it contains. This implementation is
200
- # based on an instance variable called @media_dir
198
+ # Purges the unique MMS2R::Media.media_dir directory created
199
+ # for this producer and all of the media that it contains.
201
200
 
202
201
  def purge()
203
202
  @logger.info("#{self.class} purging #{@media_dir} and all its contents") unless @logger.nil?
@@ -212,13 +211,10 @@ module MMS2R
212
211
  # media of a MMS.
213
212
  #
214
213
  # Helpers methods for the process template:
215
- # ignore_media? true if the media contained a is part should
216
- # be ignored.
217
- # process_media retrieves media to temporary file, returns path
218
- # to file.
219
- # transform_text called by process_media, strips out advertising.
220
- # temp_file creates a temporary filepath based on information from
221
- # the part.
214
+ # * ignore_media? -- true if the media contained in a part should be ignored.
215
+ # * process_media -- retrieves media to temporary file, returns path to file.
216
+ # * transform_text -- called by process_media, strips out advertising.
217
+ # * temp_file -- creates a temporary filepath based on information from the part.
222
218
 
223
219
  def process()
224
220
  @logger.info("#{self.class} processing") unless @logger.nil?
@@ -272,7 +268,7 @@ module MMS2R
272
268
  #
273
269
  # Returns a MMS2R::Media product based on the characteristics
274
270
  # of the carrier from which the the MMS originated.
275
- # mail is a TMail object, logger is a Logger and may be
271
+ # mail is a TMail object, logger is a Logger and can be
276
272
  # nil.
277
273
 
278
274
  def self.create(mail, logger=nil)
@@ -312,7 +308,7 @@ module MMS2R
312
308
  @@conf_dir = File.join(File.dirname(__FILE__), '..', '..', 'conf')
313
309
 
314
310
  ##
315
- # Set the directory where conf files are stored.
311
+ # Get the directory where conf files are stored.
316
312
 
317
313
  def self.conf_dir
318
314
  @@conf_dir
@@ -330,7 +326,7 @@ module MMS2R
330
326
 
331
327
  def self.safe_message_id(mid)
332
328
  return "#{Time.now.to_i}" if mid.nil?
333
- mid.gsub(/<|>|@|\./, "")
329
+ mid.gsub(/\$|<|>|@|\./, "")
334
330
  end
335
331
 
336
332
  ##
@@ -31,6 +31,7 @@ module MMS2R
31
31
  url = URI.parse(img)
32
32
  begin
33
33
  res = Net::HTTP.get_response(url)
34
+ res.value
34
35
  file_name ="#{img.match(/\/RECIPIENT\/([^\/]+)\//)[1]}.#{self.class.default_ext(res.content_type)}"
35
36
  type = res.content_type
36
37
  content = res.body
data/lib/mms2r/version.rb CHANGED
@@ -6,7 +6,7 @@ module MMS2R
6
6
  ##
7
7
  # MMS2R Library version
8
8
 
9
- VERSION = '1.0.4'
9
+ VERSION = '1.0.5'
10
10
 
11
11
  end
12
12
  end
@@ -0,0 +1,43 @@
1
+ Content-Type: multipart/related; boundary="45f5bb5505a8qwerty_0000"; type="multipart/alternative"
2
+ To: <tommytutone@example.com>
3
+ Date: Mon, 12 Mar 2007 20:43:01 GMT
4
+ From: 20686753909@messaging.nextel.com
5
+ Sender: "20686753909" <20686753909@messaging.nextel.com>
6
+ X-Priority: 3
7
+ MIME-Version: 1.0
8
+ Message-Id: <20070112204344.ABCD1234.adcext11.messaging.nextel.com@dadslffd>
9
+
10
+ This is a multi-part message in MIME format.
11
+
12
+ --45f5bb5505a8qwerty_0000
13
+ Content-Type: multipart/alternative; boundary="prez_1234567890_ldksjfa"
14
+
15
+
16
+ --prez_1234567890_ldksjfa
17
+ Content-Type: text/plain; charset="utf-8"
18
+
19
+ This is an MMS message. 2006 Sprint Nextel. All rights reserved.
20
+ --prez_1234567890_ldksjfa
21
+ Content-Type: text/html; charset="utf-8"
22
+
23
+ <html><body>
24
+
25
+ This is an MMS message. <br><center> 2006 Sprint Nextel. All rights reserved</center>
26
+ </body></html>
27
+
28
+ --prez_1234567890_ldksjfa--
29
+
30
+ --45f5bb5505a8qwerty_0000
31
+ Content-ID: <Mar12_0001.jpg.jpg>
32
+ Content-Type: image/jpeg; name="Mar12_0001.jpg"
33
+ Content-Disposition: inline; filename="Mar12_0001.jpg"
34
+ Content-Transfer-Encoding: base64
35
+
36
+ /9j/4AAQSkZJRgABAQEASABIAAD/4QAWRXhpZgAATU0AKgAAAAgAAAAAAAD//gAXQ3JlYXRl
37
+ ZCB3aXRoIFRoZSBHSU1Q/9sAQwAFAwQEBAMFBAQEBQUFBgcMCAcHBwcPCwsJDBEPEhIRDxER
38
+ ExYcFxMUGhURERghGBodHR8fHxMXIiQiHiQcHh8e/9sAQwEFBQUHBgcOCAgOHhQRFB4eHh4e
39
+ Hh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4e/8AAEQgAAQAB
40
+ AwEiAAIRAQMRAf/EABUAAQEAAAAAAAAAAAAAAAAAAAAH/8QAFBABAAAAAAAAAAAAAAAAAAAA
41
+ AP/EABUBAQEAAAAAAAAAAAAAAAAAAAcI/8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQAC
42
+ EQMRAD8AlgA6WW//2Q==
43
+ --45f5bb5505a8qwerty_0000--
@@ -0,0 +1,44 @@
1
+ Content-Type: multipart/related; boundary="460ffb124783qwerty_0000"; type="multipart/alternative"
2
+ To: <tommytutone@example.com>
3
+ Date: Sun, 01 Apr 2007 18:33:54 GMT
4
+ From: 2068675309@messaging.nextel.com
5
+ Sender: "2068675309" <2068675309@messaging.nextel.com>
6
+ X-Priority: 3
7
+ MIME-Version: 1.0
8
+ Message-Id: <20070401183354.MZBE2686.adcmta27.messaging.nextel.com@opwvsmtp>
9
+ Message-Id: <20070401184444.ABCD2699.afdsad29.messaging.nextel.com@fdsaddsl>
10
+
11
+ This is a multi-part message in MIME format.
12
+
13
+ --460ffb124783qwerty_0000
14
+ Content-Type: multipart/alternative; boundary="prez_1234567890_ldksjfa"
15
+
16
+
17
+ --prez_1234567890_ldksjfa
18
+ Content-Type: text/plain; charset="utf-8"
19
+
20
+ This is an MMS message. Please go to http://mms.nextel.com/mms/anon/do/legacy/viewDirect?sender=2068675309@messaging.nextel.com&recipient=tommytutone@example.com&password=1miiaa to view the message or http://mms.nextel.com/anon/do/legacy/replyDirect?sender=2068675309@messaging.nextel.com&recipient=tommytutone@example.com&password=1miiaa to reply to the message. &copy; 2006 Sprint Nextel. All rights reserved.
21
+ --prez_1234567890_ldksjfa
22
+ Content-Type: text/html; charset="utf-8"
23
+
24
+ <html><body>
25
+
26
+ This is an MMS message. Please go to <a href="http://mms.nextel.com/mms/anon/do/legacy/viewDirect?sender=2068675309@messaging.nextel.com&recipient=tommytutone@example.com&password=1miiaa"> <b> VIEW </b> </a> to view the message or <a href="http://mms.nextel.com/mms/anon/do/legacy/replyDirect?sender=2068675309@messaging.nextel.com&recipient=tommytutone@example.com&password=1miiaa"> <b> REPLY </b></a> to reply to the message. <br><center> &copy; 2006 Sprint Nextel. All rights reserved</center>.
27
+ </body></html>
28
+
29
+ --prez_1234567890_ldksjfa--
30
+
31
+ --460ffb124783qwerty_0000
32
+ Content-ID: <Apr01_0001.jpg.jpg>
33
+ Content-Type: image/jpeg; name="Apr01_0001.jpg"
34
+ Content-Disposition: inline; filename="Apr01_0001.jpg"
35
+ Content-Transfer-Encoding: base64
36
+
37
+ /9j/4AAQSkZJRgABAQEASABIAAD/4QAWRXhpZgAATU0AKgAAAAgAAAAAAAD//gAXQ3JlYXRl
38
+ ZCB3aXRoIFRoZSBHSU1Q/9sAQwAFAwQEBAMFBAQEBQUFBgcMCAcHBwcPCwsJDBEPEhIRDxER
39
+ ExYcFxMUGhURERghGBodHR8fHxMXIiQiHiQcHh8e/9sAQwEFBQUHBgcOCAgOHhQRFB4eHh4e
40
+ Hh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4e/8AAEQgAAQAB
41
+ AwEiAAIRAQMRAf/EABUAAQEAAAAAAAAAAAAAAAAAAAAH/8QAFBABAAAAAAAAAAAAAAAAAAAA
42
+ AP/EABUBAQEAAAAAAAAAAAAAAAAAAAcI/8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQAC
43
+ EQMRAD8AlgA6WW//2Q==
44
+ --460ffb124783qwerty_0000--
@@ -0,0 +1,43 @@
1
+ Content-Type: multipart/related; boundary="4600a65b3963qwerty_0000"; type="multipart/alternative"
2
+ To: <tommytutone@example.com>
3
+ Date: Wed, 21 Mar 2007 03:28:27 GMT
4
+ From: 2068675309@messaging.nextel.com
5
+ Sender: "2068675309" <2068675309@messaging.nextel.com>
6
+ X-Priority: 3
7
+ MIME-Version: 1.0
8
+ Message-Id: <20070324453543.XLZM4322.adcext07.messaging.nextel.com@adsafdds>
9
+
10
+ This is a multi-part message in MIME format.
11
+
12
+ --4600a65b3963qwerty_0000
13
+ Content-Type: multipart/alternative; boundary="prez_1234567890_ldksjfa"
14
+
15
+
16
+ --prez_1234567890_ldksjfa
17
+ Content-Type: text/plain; charset="utf-8"
18
+
19
+ This is an MMS message. 2006 Sprint Nextel. All rights reserved.
20
+ --prez_1234567890_ldksjfa
21
+ Content-Type: text/html; charset="utf-8"
22
+
23
+ <html><body>
24
+
25
+ This is an MMS message. <br><center> 2006 Sprint Nextel. All rights reserved <br></center>
26
+ </body></html>
27
+
28
+ --prez_1234567890_ldksjfa--
29
+
30
+ --4600a65b3963qwerty_0000
31
+ Content-ID: <Mar20_0001.jpg.jpg>
32
+ Content-Type: image/jpeg; name="Mar20_0001.jpg"
33
+ Content-Disposition: inline; filename="Mar20_0001.jpg"
34
+ Content-Transfer-Encoding: base64
35
+
36
+ /9j/4AAQSkZJRgABAQEASABIAAD/4QAWRXhpZgAATU0AKgAAAAgAAAAAAAD//gAXQ3JlYXRl
37
+ ZCB3aXRoIFRoZSBHSU1Q/9sAQwAFAwQEBAMFBAQEBQUFBgcMCAcHBwcPCwsJDBEPEhIRDxER
38
+ ExYcFxMUGhURERghGBodHR8fHxMXIiQiHiQcHh8e/9sAQwEFBQUHBgcOCAgOHhQRFB4eHh4e
39
+ Hh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4e/8AAEQgAAQAB
40
+ AwEiAAIRAQMRAf/EABUAAQEAAAAAAAAAAAAAAAAAAAAH/8QAFBABAAAAAAAAAAAAAAAAAAAA
41
+ AP/EABUBAQEAAAAAAAAAAAAAAAAAAAcI/8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQAC
42
+ EQMRAD8AlgA6WW//2Q==
43
+ --4600a65b3963qwerty_0000--
@@ -0,0 +1,195 @@
1
+ Message-ID: <01234567.9876543210987.JavaMail.jkdos@lalal09>
2
+ From: "someuser@pm.sprint.com" <someuser@pm.sprint.com>
3
+ To: tommytutone@example.com
4
+ Subject: You have new Picture Mail!
5
+ MIME-Version: 1.0
6
+ Content-Type: multipart/alternative;
7
+ boundary="----=_Part_012345_67890123.4567890123456"
8
+ X-Priority: 3
9
+ X-MSMail-Priority: Normal
10
+ Importance: Normal
11
+
12
+ ------=_Part_012345_67890123.4567890123456
13
+ Content-Type: text/plain; charset=us-ascii
14
+ Content-Transfer-Encoding: 7bit
15
+
16
+ You have new Picture Mail!
17
+
18
+ Click Go/View to see now.
19
+ http://pictures.sprintpcs.com/?mivt=helloworld0123456789&shareName=MMS
20
+
21
+ _abcedef
22
+
23
+
24
+ ------=_Part_012345_67890123.4567890123456
25
+ Content-Type: text/html
26
+ Content-Transfer-Encoding: 7bit
27
+
28
+ <html>
29
+ <head><title>You have new Picture Mail!</title>
30
+ <!-- lsPictureMail-Share-helloworld0123456789-comment
31
+ &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF&#45;8&quot;?&gt;
32
+ &lt;shareMessage&gt;
33
+ &lt;messageContents type=&quot;PICTURE&quot;&gt;
34
+ &lt;messageText&gt;&lt;/messageText&gt;
35
+ &lt;mediaItems&gt;
36
+ &lt;mediaItem id=&quot;1&quot;&gt;
37
+ &lt;title&gt;&lt;/title&gt;
38
+ &amp;lt;url&amp;gt;http://pictures.sprintpcs.com/getMMBOXMessageMedia?id=Xw1004H8sLv6S3x76lVPYvc9HWuygho0mqG1a5IEKWLR8s8O0GEqXAmk5gW%2FZUWGqyw0fwJJvr7U%0AtWtQs5%2FZA7tmYNq7KKkBMqlL64JVNH%2BGkNKbb8WqPL%2FsrHZdYUVet3SRzN1GfrfUo%2BpWfjCBBg%3D%3D%0A&amp;lt;/url&amp;gt;
39
+
40
+ &lt;urlExpiration&gt;2007&#45;03&#45;11T21:14:27Z&lt;/urlExpiration&gt;
41
+ &lt;/mediaItem&gt;
42
+ &lt;/mediaItems&gt;
43
+ &lt;/messageContents&gt;
44
+ &lt;/shareMessage&gt;
45
+
46
+ -->
47
+ <!-- lsPictureMail-UserInfo-helloworld0123456789-comment
48
+ &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF&#45;8&quot;?&gt;
49
+ &lt;UserInfo timestamp=&quot;2007&#45;03&#45;04T21:14:27.96+00:00&quot; originating_from_address=&quot;someuser@pm.sprint.com&quot;&gt;&lt;credential name=&quot;MDN&quot;&gt;2068509247&lt;/credential&gt;&lt;/UserInfo&gt;
50
+ -->
51
+ </head>
52
+ <body marginheight="0" marginwidth="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
53
+ <table border="0" width="100%" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" >
54
+ <tr>
55
+ <td VALIGN="top" colspan="2" width="100%">
56
+ <table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#FFE100">
57
+ <tr>
58
+ <td><a href="http://www.sprintpcs.com"><img src="http://pictures.sprintpcs.com/retailers/PCSNEXTEL/images/logos/togetherWithNextel.gif" alt="" border="0" /></a></td>
59
+ </tr>
60
+ </table>
61
+ </td>
62
+ </tr>
63
+ <tr>
64
+ <td VALIGN="top" colspan="2">
65
+ <table border="0" cellpadding="0" cellspacing="0" width="590" bgcolor="#FFFFFF">
66
+ <tr>
67
+ <td><br/><p><img src="http://pictures.sprintpcs.com/images/x.gif" border="0" width="10"/><font face="trebuchet ms, Helvetica, Arial, Verdana" size="2"><b>You have a Picture Mail from someuser@pm.sprint.com</b></font><br/><br/></p></td>
68
+ </tr>
69
+ </table>
70
+ </td>
71
+ </tr>
72
+ <tr>
73
+ <td colspan="2">
74
+ <table border="0" width="590" cellpadding="0" cellspacing="0">
75
+ <tr>
76
+ <td width="10">&nbsp;</td>
77
+ <td width="280" valign="top">
78
+ <table border="0" cellpadding="0" style="border:1px solid #9C9A9C;">
79
+ <tr>
80
+ <td>
81
+ <table border="0" bgcolor="#ffffff" cellpadding="0" cellspacing="7" style="table-layout:fixed">
82
+ <tr>
83
+ <td align="center">
84
+ <img src="http://localhost:99163/brokenimage/RECIPIENT/000_0123a01234567890_1/2?inviteToken=helloworld0123456789&amp;limitsize=258,258&amp;outquality=90&amp;squareoutput=255,255,255&amp;ext=.jpg&amp;iconifyVideo=true&amp;wm=1"/>
85
+ </td>
86
+ </tr>
87
+ </table>
88
+ </td>
89
+ </tr>
90
+ </table>
91
+ </td>
92
+ <td width="20">&nbsp;</td>
93
+ <td VALIGN="top" align="right" width="280">
94
+ <table border="0" cellpadding="0" cellspacing="0" width="280" style="table-layout:fixed">
95
+ <tr>
96
+ <td><p><font face="trebuchet ms, Helvetica, Arial, Verdana" size="2"><b>Message:</b></font></p></td>
97
+ </tr>
98
+ <tr>
99
+ <td><pre style="overflow:auto; font:normal 10pt trebuchet ms; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"></pre></td>
100
+ </tr>
101
+ <tr>
102
+ <td><img src="http://pictures.sprintpcs.com/images/x.gif" border="0" height="15"/></td>
103
+ </tr>
104
+ <tr>
105
+ <td width="280">
106
+ <div style="padding-left:10px; padding-top:4px; padding-bottom:4px; color:white; background-color:#59639C; font: bold 10pt trebuchet ms" width="280">
107
+ Options
108
+ </div>
109
+ <div style="padding:10px; background-color:#f1f1f1; font: normal 10pt trebuchet ms" width="280">
110
+ <a target="_blank" style="color: #148AB2;" href="http://pictures.sprintpcs.com/share.do?invite=helloworld0123456789&amp;shareName=MMS&amp;messageState=RETRIEVED">View Picture</a><br/>
111
+ <a target="_blank" style="color: #148AB2;" href="http://pictures.sprintpcs.com/share.do?invite=helloworld0123456789&amp;shareName=PRINT">Order Prints and Gifts</a><br/>
112
+ <a target="_blank" style="color: #148AB2;" href="http://pictures.sprintpcs.com/share.do?invite=helloworld0123456789&amp;shareName=REPLY">Reply to Sender</a><br/>
113
+ <a target="_blank" style="color: #148AB2;" href="http://pictures.sprintpcs.com/share.do?invite=helloworld0123456789&amp;shareName=REPLYTOALL">Reply to All</a><br/>
114
+ <a target="_blank" style="color: #148AB2;" href="http://pictures.sprintpcs.com/share.do?invite=helloworld0123456789&amp;shareName=FORWARD">Forward</a><br/><br/>
115
+ Send and receive Pictures and Videos through Picture Mail<sup>SM</sup>. For more information go to <a target="_blank" style="color: #148AB2;" href="http://www.sprint.com/picturemail">www.sprint.com/picturemail.</a>
116
+ </div>
117
+ </td>
118
+ </tr>
119
+ </table>
120
+ </td>
121
+ </tr>
122
+ </table>
123
+ </td>
124
+ </tr>
125
+ <tr>
126
+ <td colspan="2">
127
+ <img src="http://pictures.sprintpcs.com/images/x.gif" width="5" height="15"/>
128
+ </td>
129
+ </tr>
130
+ <tr>
131
+ <td align="left" colspan="2" width="590">
132
+ <table cellpadding="0" cellspacing="0" align="left" bgcolor="#FFFFFF">
133
+ <tr>
134
+ <td width="10">&nbsp;</td>
135
+ <td width="580">
136
+ <table cellpadding="0" cellspacing="0" align="center" border="0" bgcolor="#FFFFFF">
137
+ <tr>
138
+ <!-- AdJuggler 5.0 request
139
+ Ad Spot: email_picture-mail-invitation_1_120x85
140
+ Channel: Undefined
141
+ Ad Dimension: 120x85
142
+ Category: Undefined
143
+ Sub-category: Undefined
144
+ -->
145
+ <td width="120"><a href="http://banners.pictures.sprintpcs.com/servlet/ajrotator/361/0/clickCGI?zone=1"><img src="http://banners.pictures.sprintpcs.com/servlet/ajrotator/361/0/viewCGI?zone=1&amp;dim=135" border="0"/></a></td>
146
+ <td width="30"></td>
147
+ <!-- AdJuggler 5.0 request
148
+ Ad Spot: email_picture-mail-invitation_2_120x85
149
+ Channel: Undefined
150
+ Ad Dimension: 120x85
151
+ Category: Undefined
152
+ Sub-category: Undefined
153
+ -->
154
+ <td width="120"><a href="http://banners.pictures.sprintpcs.com/servlet/ajrotator/362/0/clickCGI?zone=1"><img src="http://banners.pictures.sprintpcs.com/servlet/ajrotator/362/0/viewCGI?zone=1&amp;dim=135" border="0"/></a></td>
155
+ <td width="30"></td>
156
+ <!-- AdJuggler 5.0 request
157
+ Ad Spot: email_picture-mail-invitation_3_120x85
158
+ Channel: Undefined
159
+ Ad Dimension: 120x85
160
+ Category: Undefined
161
+ Sub-category: Undefined
162
+ -->
163
+ <td width="120"><a href="http://banners.pictures.sprintpcs.com/servlet/ajrotator/363/0/clickCGI?zone=1"><img src="http://banners.pictures.sprintpcs.com/servlet/ajrotator/363/0/viewCGI?zone=1&amp;dim=135" border="0"/></a></td>
164
+ </tr>
165
+ </table>
166
+ </td>
167
+ </tr>
168
+ </table>
169
+ </td>
170
+ </tr>
171
+ <tr>
172
+ <td VALIGN="top" colspan="2" width="590">
173
+ <img src="http://pictures.sprintpcs.com/images/x.gif" height="5"/>
174
+ </td>
175
+ </tr>
176
+ <tr>
177
+ <td VALIGN="top" colspan="2" width="100%">
178
+ <table width="100%" border="0" cellspacing="0" cellpadding="0">
179
+ <tr>
180
+ <td bgcolor="#f1f1f1" align="left"><img src="http://pictures.sprintpcs.com/images/x.gif" border="0" width="385" height="15"/><span style="font-family:trebuchet ms, Helvetica, Arial, Verdana; Font-size: 11px; Color: #000000">&#169; 2007 Sprint Nextel. All rights reserved.</span></td>
181
+ </tr>
182
+ <tr>
183
+ <td bgcolor="#f1f1f1" width="100%"><img src="http://pictures.sprintpcs.com/images/x.gif" border="0" width="20" height="5"/><a href="http://www.verisign.com"><img src="http://pictures.sprintpcs.com/retailers/PCSNEXTEL/images/logos/verisign.jpg" alt="VeriSign's Home Page" border="0" /></a></td>
184
+ </tr>
185
+ <tr>
186
+ <td bgcolor="#f1f1f1" width="100%"><img src="http://pictures.sprintpcs.com/images/x.gif" border="0" height="10"/></td>
187
+ </tr>
188
+ </table>
189
+ </td>
190
+ </tr>
191
+ </table>
192
+ </body>
193
+ </html><!-- picture_mail_arrived -->
194
+
195
+ ------=_Part_012345_67890123.4567890123456--
@@ -0,0 +1,145 @@
1
+ Message-ID: <22602315.1176222587205.JavaMail.mms@rlysnq13>
2
+ Message-ID: <88982924.2934948848844.JavaMail.mms@zozozo33>
3
+ Date: Tue, 10 Apr 2007 09:29:47 -0700
4
+ From: 16128675309@tmomail.net
5
+ To: tommytutone@example.com
6
+ Subject: Pretty
7
+ Mime-Version: 1.0
8
+ Content-Type: multipart/related; type="text/html";
9
+ boundary="----=_Part_2223331_44455555.4556228899202"
10
+ Importance: Normal
11
+ X-MMS-Message-Type: MM4_forward.REQ
12
+ X-Priority: 3
13
+
14
+ ------=_Part_2223331_44455555.4556228899202
15
+ Content-Type: text/html
16
+ Content-Transfer-Encoding: quoted-printable
17
+ Content-ID: <0000>
18
+ Content-Disposition: inline
19
+
20
+ <html>
21
+ <head>
22
+ =09=09<title>T-Mobile</title>=20
23
+ =09=09<!--
24
+ =09=09=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
25
+ =09=09If you can read this text, but much of the message below seems unread=
26
+ able, you might be using an e-mail program that does not work with HTML.
27
+
28
+ =09=09=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D-->
29
+ =09=09<style type=3D"text/css">
30
+ <!--
31
+
32
+ =09=09.footer {
33
+ =09=09=09font-family: Arial, Helvetica, sans-serif;
34
+ =09=09=09font-size: 11px;
35
+ =09=09=09color: #555555;
36
+ =09=09=09text-decoration: none;
37
+ =09=09}
38
+ =09=09.normal {
39
+ =09=09=09font-family: Arial, Helvetica, sans-serif;
40
+ =09=09=09font-size: 10px;
41
+ =09=09=09color: #555555;
42
+ =09=09=09text-decoration: none;
43
+ =09=09}
44
+
45
+ =09=09-->
46
+ =09=09</style>
47
+ =09</head>
48
+ =09<body marginwidth=3D"0" marginheight=3D"0" leftmargin=3D"0" topmargin=3D=
49
+ "0" bgcolor=3D"#ffffff">
50
+ =09=09<table border=3D"0" width=3D"600" cellspacing=3D"0" cellpadding=3D"0"=
51
+ >
52
+ =09=09=09<tr>
53
+ =09=09=09=09<td width=3D"20" rowspan=3D"8"><img src=3D"cid:tmobilespace.gif=
54
+ " width=3D"20" height=3D"20"></td>
55
+ =09=09=09=09<td width=3D"600" colspan=3D"2"><img src=3D"cid:tmobilespace.gi=
56
+ f" width=3D"600" height=3D"20"></td>
57
+ =09=09=09=09<td width=3D"20" rowspan=3D"8"><img src=3D"cid:tmobilespace.gif=
58
+ " width=3D"20" height=3D"20"></td>
59
+ =09=09=09</tr>
60
+ =09=09=09<tr>
61
+ =09=09=09=09<td width=3D"600" colspan=3D"2"><img src=3D"cid:dottedline600.g=
62
+ if" width=3D"600"></td>
63
+ =09=09=09</tr>
64
+ =09=09=09<tr>
65
+ =09=09=09=09<td width=3D"370">
66
+ =09=09=09=09 <!-- presentation starts here -->
67
+ =09=09=09=09 <table border=3D0><tr><tr><td colspan=3D1 align=3D"Left"><IM=
68
+ G align=3Dbaseline alt=3D"" border=3D0 hspace=3D0 src=3D"cid:761"></td></tr=
69
+ ><tr><td colspan=3D1 align=3D"Left">Lillies</td></tr></tr><TR><TD width=3D3=
70
+ 50 colSpan=3D1><IMG height=3D30 src=3D"cid:tmobilespace.gif" width=3D350><=
71
+ /TD></TR><TR><TD width=3D350 colSpan=3D4><IMG src=3D"cid:dottedline350.gif"=
72
+ width=3D350></TD></TR><TR><TR><TD width=3D350 colSpan=3D4><IMG height=3D3=
73
+ 0 src=3D"cid:tmobilespace.gif" width=3D350></TD></TR></table>=20
74
+ =09=09=09=09 <!-- presentation ends here -->
75
+ =09=09=09=09</td>
76
+ =09=09=09=09<td width=3D"240" bgcolor=3D"#f2f2f2"><BR></td>
77
+ =09=09=09</tr>
78
+ <tr>
79
+ =09=09=09=09<td width=3D"600" colspan=3D"2"><img src=3D"cid:tmobilelogo.gif=
80
+ " width=3D"600" height=3D"105"></td>
81
+ </tr>
82
+ <tr>
83
+ =09=09=09=09<td width=3D"600" colspan=3D"2"><img src=3D"cid:tmobilespace.gi=
84
+ f" width=3D"600" height=3D"40"></td>
85
+ </tr>
86
+ </table>
87
+ </body></html>
88
+
89
+ ------=_Part_2223331_44455555.4556228899202
90
+ Content-Type: text/plain; name=smiltextpartfilename0.txt; charset=utf-8
91
+ Content-Transfer-Encoding: 7bit
92
+ Content-Location: smiltextpartfilename0.txt
93
+ Content-ID: <760>
94
+ Content-Disposition: inline
95
+
96
+ Lillies
97
+ ------=_Part_2223331_44455555.4556228899202
98
+ Content-Type: image/jpeg; name=07-25-05_0935.jpg
99
+ Content-Transfer-Encoding: base64
100
+ Content-Location: 07-25-05_0935.jpg
101
+ Content-ID: <761>
102
+
103
+ /9j/4AAQSkZJRgABAQEASABIAAD/4QAWRXhpZgAATU0AKgAAAAgAAAAAAAD//gAXQ3JlYXRl
104
+ ZCB3aXRoIFRoZSBHSU1Q/9sAQwAFAwQEBAMFBAQEBQUFBgcMCAcHBwcPCwsJDBEPEhIRDxER
105
+ ExYcFxMUGhURERghGBodHR8fHxMXIiQiHiQcHh8e/9sAQwEFBQUHBgcOCAgOHhQRFB4eHh4e
106
+ Hh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4e/8AAEQgAAQAB
107
+ AwEiAAIRAQMRAf/EABUAAQEAAAAAAAAAAAAAAAAAAAAH/8QAFBABAAAAAAAAAAAAAAAAAAAA
108
+ AP/EABUBAQEAAAAAAAAAAAAAAAAAAAcI/8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQAC
109
+ EQMRAD8AlgA6WW//2Q==
110
+ ------=_Part_2223331_44455555.4556228899202
111
+ Content-Type: image/gif; name=dottedline350.gif
112
+ Content-Transfer-Encoding: base64
113
+ Content-Disposition: attachment; filename=dottedline350.gif
114
+ Content-ID: <dottedline350.gif>
115
+
116
+ R0lGODlhAQABAIAAAP///wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==
117
+ ------=_Part_2223331_44455555.4556228899202
118
+ Content-Type: image/gif; name=audio.gif
119
+ Content-Transfer-Encoding: base64
120
+ Content-Disposition: attachment; filename=audio.gif
121
+ Content-ID: <audio.gif>
122
+
123
+ R0lGODlhAQABAIAAAP///wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==
124
+ ------=_Part_2223331_44455555.4556228899202
125
+ Content-Type: image/gif; name=dottedline600.gif
126
+ Content-Transfer-Encoding: base64
127
+ Content-Disposition: attachment; filename=dottedline600.gif
128
+ Content-ID: <dottedline600.gif>
129
+
130
+ R0lGODlhAQABAIAAAP///wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==
131
+ ------=_Part_2223331_44455555.4556228899202
132
+ Content-Type: image/gif; name=tmobilelogo.gif
133
+ Content-Transfer-Encoding: base64
134
+ Content-Disposition: attachment; filename=tmobilelogo.gif
135
+ Content-ID: <tmobilelogo.gif>
136
+
137
+ R0lGODlhAQABAIAAAP///wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==
138
+ ------=_Part_2223331_44455555.4556228899202
139
+ Content-Type: image/gif; name=tmobilespace.gif
140
+ Content-Transfer-Encoding: base64
141
+ Content-Disposition: attachment; filename=tmobilespace.gif
142
+ Content-ID: <tmobilespace.gif>
143
+
144
+ R0lGODlhAQABAIAAAP///wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==
145
+ ------=_Part_2223331_44455555.4556228899202--
@@ -0,0 +1,50 @@
1
+ X-Priority: 3
2
+ Importance: Normal
3
+ From: 7018675309@vzwpix.com
4
+ To: tommytutone@example.com
5
+ Subject: Pic
6
+ Message-ID: <777784777736662222@-223349988121212333>
7
+ Date: Mon, 9 Apr 2007 12:14:29 -0400
8
+ MIME-Version: 1.0
9
+ Content-Type: multipart/mixed;
10
+ type="application/smil";
11
+ boundary="__CONTENT_77888_PART_BOUNDARY__99922233__"
12
+ X-MailShield-Spam-Score: 10
13
+ X-DNSBL-Score: 0
14
+ X-SMTP-HELO: m01.vzwpix.com
15
+ X-SMTP-MAIL-FROM: 7018675309@vzwpix.com
16
+ X-SMTP-RCPT-TO: tommytutone@example.com
17
+
18
+ --__CONTENT_77888_PART_BOUNDARY__99922233__
19
+ Content-Type: text/plain;
20
+ charset=utf-8;
21
+ name="smiltextpartfilename0.txt"
22
+ Content-ID: <smiltextpartfilename0.txt>
23
+ Content-Location: smiltextpartfilename0.txt
24
+
25
+ ? Weird
26
+
27
+ This message was sent using PIX-FLIX Messaging service from Verizon Wireless!
28
+ To learn how you can snap pictures with your wireless phone visit
29
+ www.verizonwireless.com/getitnow/getpix.
30
+
31
+ To learn how you can record videos with your wireless phone visit www.verizonwireless.com/getitnow/getflix.
32
+
33
+ To play video messages sent to email, QuickTime� 6.5 or higher is required. Visit www.apple.com/quicktime/download to download the free player or upgrade your existing QuickTime� Player. Note: During the download
34
+ process when asked to choose an installation type (Minimum, Recommended or Custom), select Minimum for faster download.
35
+
36
+ --__CONTENT_77888_PART_BOUNDARY__99922233__
37
+ Content-Type: image/jpeg;
38
+ name="04-09-07_1114.jpg"
39
+ Content-ID: <04-09-07_1114.jpg>
40
+ Content-Location: 04-09-07_1114.jpg
41
+ Content-Transfer-Encoding: base64
42
+
43
+ /9j/4AAQSkZJRgABAQEASABIAAD/4QAWRXhpZgAATU0AKgAAAAgAAAAAAAD//gAXQ3JlYXRl
44
+ ZCB3aXRoIFRoZSBHSU1Q/9sAQwAFAwQEBAMFBAQEBQUFBgcMCAcHBwcPCwsJDBEPEhIRDxER
45
+ ExYcFxMUGhURERghGBodHR8fHxMXIiQiHiQcHh8e/9sAQwEFBQUHBgcOCAgOHhQRFB4eHh4e
46
+ Hh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4e/8AAEQgAAQAB
47
+ AwEiAAIRAQMRAf/EABUAAQEAAAAAAAAAAAAAAAAAAAAH/8QAFBABAAAAAAAAAAAAAAAAAAAA
48
+ AP/EABUBAQEAAAAAAAAAAAAAAAAAAAcI/8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQAC
49
+ EQMRAD8AlgA6WW//2Q==
50
+ --__CONTENT_77888_PART_BOUNDARY__99922233__--
@@ -15,7 +15,7 @@ class MMS2RCingularTest < Test::Unit::TestCase
15
15
  @log.datetime_format = "%H:%M:%S"
16
16
  end
17
17
 
18
- def teadown; end
18
+ def teardown; end
19
19
 
20
20
  def test_clean_text_ad
21
21
  mail = TMail::Mail.parse(load_mail('cingularme-text-01.mail').join)
@@ -14,7 +14,7 @@ class MMS2RMModeTest < Test::Unit::TestCase
14
14
  @log.datetime_format = "%H:%M:%S"
15
15
  end
16
16
 
17
- def teadown; end
17
+ def teardown; end
18
18
 
19
19
  def test_simple
20
20
  mail = TMail::Mail.parse(load_mail('mmode-image-01.mail').join)
@@ -15,9 +15,9 @@ class MMS2RNextelTest < Test::Unit::TestCase
15
15
  @log.datetime_format = "%H:%M:%S"
16
16
  end
17
17
 
18
- def teadown; end
18
+ def teardown; end
19
19
 
20
- def test_simple_image
20
+ def test_simple_image1
21
21
  mail = TMail::Mail.parse(load_mail('nextel-image-01.mail').join)
22
22
  mms = MMS2R::Media.create(mail)
23
23
  mms.process
@@ -36,6 +36,63 @@ class MMS2RNextelTest < Test::Unit::TestCase
36
36
  mms.purge
37
37
  end
38
38
 
39
+ def test_simple_image2
40
+ mail = TMail::Mail.parse(load_mail('nextel-image-02.mail').join)
41
+ mms = MMS2R::Media.create(mail)
42
+ mms.process
43
+
44
+ assert(mms.media.size == 1)
45
+ assert_nil(mms.media['text/plain'])
46
+ assert_nil(mms.media['text/html'])
47
+ assert_not_nil(mms.media['image/jpeg'][0])
48
+ assert_match(/Mar12_0001.jpg$/, mms.media['image/jpeg'][0])
49
+
50
+ file = mms.media['image/jpeg'][0]
51
+ assert_not_nil(file)
52
+ assert(File::exist?(file), "file #{file} does not exist")
53
+ assert(File::size(file) == 337, "file #{file} not 337 byts")
54
+
55
+ mms.purge
56
+ end
57
+
58
+ def test_simple_image3
59
+ mail = TMail::Mail.parse(load_mail('nextel-image-03.mail').join)
60
+ mms = MMS2R::Media.create(mail)
61
+ mms.process
62
+
63
+ assert(mms.media.size == 1)
64
+ assert_nil(mms.media['text/plain'])
65
+ assert_nil(mms.media['text/html'])
66
+ assert_not_nil(mms.media['image/jpeg'][0])
67
+ assert_match(/Apr01_0001.jpg$/, mms.media['image/jpeg'][0])
68
+
69
+ file = mms.media['image/jpeg'][0]
70
+ assert_not_nil(file)
71
+ assert(File::exist?(file), "file #{file} does not exist")
72
+ assert(File::size(file) == 337, "file #{file} not 337 byts")
73
+
74
+ mms.purge
75
+ end
76
+
77
+ def test_simple_image4
78
+ mail = TMail::Mail.parse(load_mail('nextel-image-04.mail').join)
79
+ mms = MMS2R::Media.create(mail)
80
+ mms.process
81
+
82
+ assert(mms.media.size == 1)
83
+ assert_nil(mms.media['text/plain'])
84
+ assert_nil(mms.media['text/html'])
85
+ assert_not_nil(mms.media['image/jpeg'][0])
86
+ assert_match(/Mar20_0001.jpg$/, mms.media['image/jpeg'][0])
87
+
88
+ file = mms.media['image/jpeg'][0]
89
+ assert_not_nil(file)
90
+ assert(File::exist?(file), "file #{file} does not exist")
91
+ assert(File::size(file) == 337, "file #{file} not 337 byts")
92
+
93
+ mms.purge
94
+ end
95
+
39
96
  private
40
97
  def load_mail(file)
41
98
  IO.readlines("#{File.dirname(__FILE__)}/files/#{file}")
@@ -21,6 +21,14 @@ class SimpleImageServlet < WEBrick::HTTPServlet::AbstractServlet
21
21
  end
22
22
  end
23
23
 
24
+ class BrokenImageServlet < WEBrick::HTTPServlet::AbstractServlet
25
+ def do_GET(req, res)
26
+ res['Content-Type'] = "text/html"
27
+ res.code = 404
28
+ res.body = '<html><head><title>404 Not Found</title></head><body><h1>Not Found</h1></body></html>'
29
+ end
30
+ end
31
+
24
32
  class SimpleVideoServlet < WEBrick::HTTPServlet::AbstractServlet
25
33
  def do_GET(req, res)
26
34
  res['Content-Type'] = "video/quicktime"
@@ -41,6 +49,7 @@ class Net::HTTP
41
49
 
42
50
  SERVLETS = {
43
51
  '/simpleimage' => SimpleImageServlet,
52
+ '/brokenimage' => BrokenImageServlet,
44
53
  '/simplevideo' => SimpleVideoServlet
45
54
  }
46
55
 
@@ -85,6 +94,11 @@ class Response
85
94
  def read_body
86
95
  yield body
87
96
  end
97
+
98
+ def value()
99
+ return body if "200".eql?(@code)
100
+ raise Net::HTTPError.new('400 Bad Request', 'Good Bye')
101
+ end
88
102
  end
89
103
 
90
104
  class MMS2RSprintTest < Test::Unit::TestCase
@@ -133,6 +147,16 @@ class MMS2RSprintTest < Test::Unit::TestCase
133
147
  mms.purge
134
148
  end
135
149
 
150
+ def test_broken_image
151
+ mail = TMail::Mail.parse(load_mail('sprint-image-02.mail').join)
152
+ mms = MMS2R::Media.create(mail)
153
+ mms.process
154
+
155
+ assert(mms.media.size == 0)
156
+
157
+ mms.purge
158
+ end
159
+
136
160
  def test_simple_text
137
161
  mail = TMail::Mail.parse(load_mail('sprint-text-01.mail').join)
138
162
  mms = MMS2R::Media.create(mail)
@@ -14,7 +14,7 @@ class MMS2RTMobileTest < Test::Unit::TestCase
14
14
  @log.datetime_format = "%H:%M:%S"
15
15
  end
16
16
 
17
- def teadown; end
17
+ def teardown; end
18
18
 
19
19
  def test_ignore_simple_image
20
20
  mail = TMail::Mail.parse(load_mail('tmobile-image-01.mail').join)
@@ -34,6 +34,30 @@ class MMS2RTMobileTest < Test::Unit::TestCase
34
34
 
35
35
  mms.purge
36
36
  end
37
+
38
+ def test_message_with_body_text
39
+ mail = TMail::Mail.parse(load_mail('tmobile-image-02.mail').join)
40
+ mms = MMS2R::Media.create(mail)
41
+ mms.process
42
+
43
+ assert(mms.media.size == 2)
44
+ assert_not_nil(mms.media['text/plain'])
45
+ assert_nil(mms.media['text/html'])
46
+ assert_not_nil(mms.media['image/jpeg'][0])
47
+ assert_match(/07-25-05_0935.jpg$/, mms.media['image/jpeg'][0])
48
+
49
+ file = mms.media['image/jpeg'][0]
50
+ assert(File::exist?(file), "file #{file} does not exist")
51
+ assert(File::size(file) == 337, "file #{file} is not 337 bytes")
52
+
53
+ file = mms.media['text/plain'][0]
54
+ assert_not_nil(file)
55
+ assert(File::exist?(file), "file #{file} does not exist")
56
+ text = IO.readlines("#{file}").join
57
+ assert_equal "Lillies", text.strip
58
+
59
+ mms.purge
60
+ end
37
61
 
38
62
  private
39
63
  def load_mail(file)
@@ -15,7 +15,7 @@ class MMS2RVerizonTest < Test::Unit::TestCase
15
15
  @log.datetime_format = "%H:%M:%S"
16
16
  end
17
17
 
18
- def teadown; end
18
+ def teardown; end
19
19
 
20
20
  def test_simple_video
21
21
  mail = TMail::Mail.parse(load_mail('verizon-video-01.mail').join)
@@ -80,6 +80,31 @@ class MMS2RVerizonTest < Test::Unit::TestCase
80
80
  assert_match(/hello world/, text)
81
81
  mms.purge
82
82
  end
83
+
84
+ def test_image_with_body_text
85
+ mail = TMail::Mail.parse(load_mail('verizon-image-02.mail').join)
86
+ mms = MMS2R::Media.create(mail)
87
+ mms.process
88
+
89
+ assert(mms.media.size == 2)
90
+ assert_not_nil(mms.media['text/plain'])
91
+ assert_nil(mms.media['text/html'])
92
+ assert_not_nil(mms.media['image/jpeg'][0])
93
+ assert_match(/04-09-07_1114.jpg$/, mms.media['image/jpeg'][0])
94
+
95
+ file = mms.media['image/jpeg'][0]
96
+ assert_not_nil(file)
97
+ assert(File::exist?(file), "file #{file} does not exist")
98
+ assert(File::size(file) == 337, "file #{file} not 337 byts")
99
+
100
+ file = mms.media['text/plain'][0]
101
+ assert_not_nil(file)
102
+ assert(File::exist?(file), "file #{file} does not exist")
103
+ text = IO.readlines("#{file}").join
104
+ assert_equal "? Weird", text
105
+
106
+ mms.purge
107
+ end
83
108
 
84
109
  private
85
110
  def load_mail(file)
metadata CHANGED
@@ -3,15 +3,15 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: mms2r
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.4
7
- date: 2007-04-10 00:00:00 -07:00
6
+ version: 1.0.5
7
+ date: 2007-04-11 00:00:00 -07:00
8
8
  summary: Extract media from MMS
9
9
  require_paths:
10
10
  - lib
11
11
  email: mike@mondragon.cc
12
12
  homepage: http://mms2r.rubyforge.org/
13
13
  rubyforge_project: mms2r
14
- description: "== DESCRIPTION: MMS2R is a library that decodes the parts of an MMS message to disk while stripping out advertising injected by the cellphone 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 garbage 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. Corpus of carriers currently processed by MMS2R: * AT&T/Cingular => mmode.com * Cingular => mms.mycingular.com * Cingular => cingularme.com * Nextel => messaging.nextel.com * Sprint => pm.sprint.com * Sprint => messaging.sprintpcs.com * T-Mobile => tmomail.net * Verizon => vzwpix.com * Verizon => vtext.com"
14
+ description: "== DESCRIPTION: MMS2R is a library that decodes the parts of an MMS message to disk while stripping out advertising injected by the cellphone 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 garbage 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: * AT&T/Cingular => mmode.com * Cingular => mms.mycingular.com * Cingular => cingularme.com * Nextel => messaging.nextel.com * Sprint => pm.sprint.com * Sprint => messaging.sprintpcs.com * T-Mobile => tmomail.net * Verizon => vzwpix.com * Verizon => vtext.com"
15
15
  autorequire:
16
16
  default_executable:
17
17
  bindir: bin
@@ -38,6 +38,7 @@ files:
38
38
  - conf/mms2r_sprintmedia_ignore.yml
39
39
  - conf/mms2r_tmobilemedia_ignore.yml
40
40
  - conf/mms2r_verizonmedia_ignore.yml
41
+ - conf/mms2r_verizonmedia_transform.yml
41
42
  - lib/mms2r.rb
42
43
  - lib/mms2r/cingular_media.rb
43
44
  - lib/mms2r/media.rb
@@ -78,14 +79,20 @@ files:
78
79
  - test/files/hello_world_mail_plain_with_content_type.mail
79
80
  - test/files/mmode-image-01.mail
80
81
  - test/files/nextel-image-01.mail
82
+ - test/files/nextel-image-02.mail
83
+ - test/files/nextel-image-03.mail
84
+ - test/files/nextel-image-04.mail
81
85
  - test/files/simple_image.mail
82
86
  - test/files/simple_multipart_alternative.mail
83
87
  - test/files/sprint-image-01.mail
88
+ - test/files/sprint-image-02.mail
84
89
  - test/files/sprint-text-01.mail
85
90
  - test/files/sprint-video-01.mail
86
91
  - test/files/sprint.mov
87
92
  - test/files/tmobile-image-01.mail
93
+ - test/files/tmobile-image-02.mail
88
94
  - test/files/verizon-image-01.mail
95
+ - test/files/verizon-image-02.mail
89
96
  - test/files/verizon-text-01.mail
90
97
  - test/files/verizon-video-01.mail
91
98
  - test/files/vtext-text-01.mail