mms2r 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ == 1.0.7 / 2007-04-27 (Senator Stampingston)
2
+
3
+ * patch submitted by Luke Francl
4
+ * added a get_subject method that returns nil when any MMS has a default carrier subject
5
+ * get_subject returns nil for '', 'Multimedia message', '(no subject)', 'You have new Picture Mail!'
6
+
1
7
  == 1.0.6 / 2007-04-24 (Pickles the Drummer)
2
8
 
3
9
  * patch submitted by Luke Francl
data/Manifest.txt CHANGED
@@ -42,6 +42,7 @@ lib/vendor/tmail/scanner_r.rb
42
42
  lib/vendor/tmail/stringio.rb
43
43
  lib/vendor/tmail/tmail.rb
44
44
  lib/vendor/tmail/utils.rb
45
+ test/files/cingular-image-01.mail
45
46
  test/files/cingularme-text-01.mail
46
47
  test/files/dobson-image-01.mail
47
48
  test/files/dot.jpg
data/README.txt CHANGED
@@ -50,6 +50,8 @@ Corpus of carriers currently processed by MMS2R:
50
50
  # writes the user generated media to disk in a temporary subdirectory
51
51
  mms.process
52
52
 
53
+ puts "MMS has default carrier subject!" if mms.get_subject.nil?
54
+
53
55
  # most MMS are either image or video, get_media will blindly return
54
56
  # the first video or image found
55
57
  file = mms.get_media
data/lib/mms2r/media.rb CHANGED
@@ -109,6 +109,19 @@ module MMS2R
109
109
  self.class.safe_message_id(@mail.message_id))
110
110
  end
111
111
 
112
+ # Filter some common place holder subjects from MMS messages and replace
113
+ # them with nil.
114
+
115
+ def get_subject
116
+ subject = @mail.subject
117
+ if subject.nil? || subject.strip.length == 0 ||
118
+ subject =~ /^(Multimedia message|\(no subject\)|You have new Picture Mail!)$/
119
+ return nil
120
+ end
121
+
122
+ subject
123
+ end
124
+
112
125
  # Returns a File with the most likely candidate for the user-submitted
113
126
  # media. Given that most MMS messages only have one file attached,
114
127
  # this will try to give you that file. First it looks for videos, then
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.6'
9
+ VERSION = '1.0.7'
10
10
 
11
11
  end
12
12
  end
@@ -0,0 +1,66 @@
1
+ Delivered-To: luke@example.com
2
+ Received: by 10.35.66.7 with SMTP id t7cs256749pyk;
3
+ Tue, 24 Apr 2007 16:40:50 -0700 (PDT)
4
+ Received: by 10.64.143.12 with SMTP id q12mr104771qbd.1177458050520;
5
+ Tue, 24 Apr 2007 16:40:50 -0700 (PDT)
6
+ Return-Path: <3105550101@mms.mycingular.com>
7
+ Received: from iad2.emailsrvr.com (iad2.emailsrvr.com [207.97.227.212])
8
+ by mx.google.com with ESMTP id 7si86743nzn.2007.04.24.16.40.46;
9
+ Tue, 24 Apr 2007 16:40:50 -0700 (PDT)
10
+ Received-SPF: neutral (google.com: 207.97.227.212 is neither permitted nor denied by best guess record for domain of 3105550101@mms.mycingular.com)
11
+ Received: by mail41a.mail.iad.mlsrvr.com (SMTP Server, from userid 5000)
12
+ id 0B65D514083; Tue, 24 Apr 2007 19:40:45 -0400 (EDT)
13
+ Received: from gate16.gate.iad.mlsrvr.com (gate16.gate.iad.mlsrvr.com [192.168.1.36])
14
+ by mail41a.mail.iad.mlsrvr.com (SMTP Server) with ESMTP id F3302514081
15
+ for <go@example.com>; Tue, 24 Apr 2007 19:40:44 -0400 (EDT)
16
+ Received: from gate1.gate.sat.mlsrvr.com (gate.sat.emailsrvr.com [66.216.121.101])
17
+ by gate16.gate.iad.mlsrvr.com (SMTP Server) with ESMTP id BA6FB1380D7
18
+ for <go@example.com>; Tue, 24 Apr 2007 19:40:44 -0400 (EDT)
19
+ X-Virus-Scanned: OK, w
20
+ X-Spam-Score: -
21
+ X-Spam-Level:
22
+ X-Spam-Status: No, score=x tagged_above=-100 required=10 WHITELISTED tests=[]
23
+ Received: from atlmtaow02.cingularme.com (atlmtaow02.cingularme.com [66.102.165.7])
24
+ by gate1.gate.sat.mlsrvr.com (SMTP Server) with ESMTP id 4C1F71B4006
25
+ for <go@example.com>; Tue, 24 Apr 2007 19:40:44 -0400 (EDT)
26
+ X-Mms-MMS-Version: 18
27
+ Date: Tue, 24 Apr 2007 19:40:43 -0400
28
+ X-Mms-Sender-Visibility: 1
29
+ X-Nokia-Ag-Internal: ; smiltype=true; internaldate=1177458043783
30
+ Content-Type: multipart/mixed; boundary="----=_Part_2944038_406917.1177458043793"
31
+ X-Mms-Delivery-Report: 1
32
+ Received: from alpagw02 ([209.183.34.196]) by atlmtaow02.cingularme.com (InterMail vM.6.01.04.00 201-2131-118-20041027) with ESMTP id <20070424234043.EHXN2345.atlmtaow02.cingularme.com@alpagw02> for <go@example.com>; Tue, 24 Apr 2007 19:40:43 -0400
33
+ X-Mms-Transaction-ID: 1-5190f9
34
+ From: <3105550101@mms.mycingular.com>
35
+ To: go@example.com
36
+ X-Mms-Message-Class: 0
37
+ X-Mms-Read-Reply: 1
38
+ Mime-Version: 1.0
39
+ Message-ID: <18398745.1177458043793.JavaMail.wluser@alpagw02>
40
+ X-Mms-Priority: 1
41
+ X-Mms-Message-Type: 0
42
+ Subject: Multimedia message
43
+ X-Nokia-Ag-Version: 2.0
44
+
45
+ ------=_Part_2944038_406917.1177458043793
46
+ Content-Type: text/plain; charset=utf-8
47
+ Content-Transfer-Encoding: base64
48
+ Content-Location: smil.txt
49
+ Content-Disposition: inline
50
+
51
+ V2F0ZXI=
52
+ ------=_Part_2944038_406917.1177458043793
53
+ Content-Type: image/jpeg;Name=04-18-07_1723.jpg
54
+ content-location: media1.jpeg
55
+ content-id: <media1.jpeg>
56
+ Content-Transfer-Encoding: base64
57
+
58
+ /9j/4AAQSkZJRgABAQEASABIAAD/4QAWRXhpZgAATU0AKgAAAAgAAAAAAAD//gAXQ3JlYXRl
59
+ ZCB3aXRoIFRoZSBHSU1Q/9sAQwAFAwQEBAMFBAQEBQUFBgcMCAcHBwcPCwsJDBEPEhIRDxER
60
+ ExYcFxMUGhURERghGBodHR8fHxMXIiQiHiQcHh8e/9sAQwEFBQUHBgcOCAgOHhQRFB4eHh4e
61
+ Hh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4e/8AAEQgAAQAB
62
+ AwEiAAIRAQMRAf/EABUAAQEAAAAAAAAAAAAAAAAAAAAH/8QAFBABAAAAAAAAAAAAAAAAAAAA
63
+ AP/EABUBAQEAAAAAAAAAAAAAAAAAAAcI/8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQAC
64
+ EQMRAD8AlgA6WW//2Q==
65
+ ------=_Part_2944038_406917.1177458043793--
66
+
@@ -36,4 +36,23 @@ class MMS2RCingularTest < Test::Unit::TestCase
36
36
  assert_match(/#{good_text}/m, text)
37
37
  mms.purge
38
38
  end
39
+
40
+ def test_image
41
+ mail = TMail::Mail.parse(load_mail('cingular-image-01.mail').join)
42
+ mms = MMS2R::Media.create(mail)
43
+ assert_equal(MMS2R::CingularMedia, mms.class, "expected a #{MMS2R::CingularMedia} and received a #{mms.class}")
44
+ mms.process
45
+
46
+ assert(mms.media.size == 2, "Size is #{mms.media.size}")
47
+ assert_not_nil(mms.media['text/plain'])
48
+ assert_not_nil(mms.media['image/jpeg'][0])
49
+ assert_match(/04-18-07_1723.jpg$/, mms.media['image/jpeg'][0])
50
+
51
+ assert_equal(nil, mms.get_subject, "Default Cingular subject not stripped")
52
+ assert_file_size(mms.media['image/jpeg'][0], 337)
53
+
54
+ assert_equal("Water", IO.readlines(mms.get_text.path).join)
55
+
56
+ mms.purge
57
+ end
39
58
  end
@@ -288,4 +288,23 @@ class MMS2RMediaTest < Test::Unit::TestCase
288
288
  mail = TMail::Mail.parse(load_mail('simple_image.mail').join)
289
289
  assert(MMS2R::Media.sub_type?(mail.parts[0]).eql?('gif'))
290
290
  end
291
+
292
+ def test_get_subject
293
+ subjects = [nil, '', 'Multimedia message', '(no subject)', 'You have new Picture Mail!']
294
+
295
+ subjects.each{|s|
296
+ mail = TMail::Mail.parse(load_mail('hello_world_mail_plain_no_content_type.mail').join)
297
+ mail.subject = s
298
+ mms = MMS2R::Media.create(mail)
299
+ mms.process
300
+ assert_equal(nil, mms.get_subject)
301
+ mms.purge
302
+ }
303
+
304
+ mail = TMail::Mail.parse(load_mail('hello_world_mail_plain_no_content_type.mail').join)
305
+ mms = MMS2R::Media.create(mail)
306
+ mms.process
307
+ assert_equal('text only', mms.get_subject)
308
+ mms.purge
309
+ end
291
310
  end
@@ -124,6 +124,9 @@ class MMS2RSprintTest < Test::Unit::TestCase
124
124
  assert_match(/000_0123a01234567895_1.mov$/, mms.media['video/quicktime'][0])
125
125
 
126
126
  assert_file_size(mms.media['video/quicktime'][0], 49063)
127
+
128
+ assert_equal(nil, mms.get_subject, "Default Sprint subject not scrubbed.")
129
+
127
130
  mms.purge
128
131
  end
129
132
 
@@ -139,6 +142,9 @@ class MMS2RSprintTest < Test::Unit::TestCase
139
142
  assert_match(/000_0123a01234567890_1.jpg$/, mms.media['image/jpeg'][0])
140
143
 
141
144
  assert_file_size(mms.media['image/jpeg'][0], 337)
145
+
146
+ assert_equal(nil, mms.get_subject, "Default Sprint subject not scrubbed")
147
+
142
148
  mms.purge
143
149
  end
144
150
 
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.2
2
+ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: mms2r
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.6
7
- date: 2007-04-25 00:00:00 -07:00
6
+ version: 1.0.7
7
+ date: 2007-04-27 00:00:00 -07:00
8
8
  summary: Extract media from MMS
9
9
  require_paths:
10
10
  - lib
@@ -73,6 +73,7 @@ files:
73
73
  - lib/vendor/tmail/stringio.rb
74
74
  - lib/vendor/tmail/tmail.rb
75
75
  - lib/vendor/tmail/utils.rb
76
+ - test/files/cingular-image-01.mail
76
77
  - test/files/cingularme-text-01.mail
77
78
  - test/files/dobson-image-01.mail
78
79
  - test/files/dot.jpg