mms2r 1.1.11 → 1.1.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,9 @@
1
+ == 1.1.12 / 2007-10-21 (Dr. Ronald von Moldenberg - Endorsement specialist)
2
+
3
+ * fetch orginal images from Sprint content server (Layton Wedgeworth)
4
+ * ignore Sprint messages when requested content has been purged from their
5
+ content server
6
+
1
7
  == 1.1.11 / 2007-10-20 (Dr. Armand Skagerakk Frederickshaven)
2
8
 
3
9
  * minor fix for attachment_fu where it might call #path on the cgi temp file
@@ -89,6 +89,7 @@ test/fixtures/simple_multipart_alternative.mail
89
89
  test/fixtures/sprint-broken-image-01.mail
90
90
  test/fixtures/sprint-image-01.mail
91
91
  test/fixtures/sprint-pcs-text-01.mail
92
+ test/fixtures/sprint-purged-image-01.mail
92
93
  test/fixtures/sprint-text-01.mail
93
94
  test/fixtures/sprint-two-images-01.mail
94
95
  test/fixtures/sprint-video-01.mail
@@ -1,4 +1,6 @@
1
1
  ---
2
+ text/html:
3
+ - !ruby/regexp /Ze're sorry, this page is not available. We apologize for the inconvenience./
2
4
  text/plain:
3
5
  - !ruby/regexp /^You have new Picture Mail! Click Go/View to see now./
4
6
  - !ruby/regexp /^You have new Video Mail! Click Go/View to see now./
@@ -67,7 +67,7 @@ module MMS2R
67
67
  ##
68
68
  # MMS2R Library version
69
69
 
70
- VERSION = '1.1.11'
70
+ VERSION = '1.1.12'
71
71
 
72
72
  end
73
73
 
@@ -1,6 +1,7 @@
1
1
  require 'net/http'
2
2
  require 'rubygems'
3
3
  require 'hpricot'
4
+ require 'cgi'
4
5
 
5
6
  module MMS2R
6
7
 
@@ -117,7 +118,14 @@ module MMS2R
117
118
  cnt = 0
118
119
  srcs.each do |src|
119
120
  begin
120
- url = URI.parse(src)
121
+ # clean out the limiting parameters for images for the content server
122
+ # to get at the original image
123
+ url = URI.parse(CGI.unescapeHTML(src))
124
+ query={}
125
+ url.query.split('&').each{|a| p=a.split('='); query[p[0]] = p[1]}
126
+ query.delete_if{|k, v| k == 'limitsize' or k == 'squareoutput' }
127
+ url.query = query.map{|k,v| "#{k}=#{v}"}.join("&")
128
+
121
129
  #res = Net::HTTP.get_response(url)
122
130
  #lets be vanilla stealth
123
131
  agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322)"
@@ -125,11 +133,18 @@ module MMS2R
125
133
  req = Net::HTTP::Get.new(url.request_uri, {'User-Agent' => agent})
126
134
  http.request(req)
127
135
  end
128
- rescue
136
+ rescue StandardError => err
129
137
  @logger.error("#{self.class} processing error, #{$!}") unless @logger.nil?
130
138
  next
131
139
  end
132
140
 
141
+ # if the Sprint content server uses response code 500 when the content is purged
142
+ # the content type will text/html and the body will be the message
143
+ if res.content_type == 'text/html' && res.code = 500
144
+ @logger.error("Sprint content server returned response code 500") unless @logger.nil?
145
+ next
146
+ end
147
+
133
148
  # setup the file path and file
134
149
  base = /\/RECIPIENT\/([^\/]+)\//.match(src)[1]
135
150
  type = res.content_type
@@ -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/mmps/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&amp;HACK=PURGED"/>
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--
@@ -30,6 +30,28 @@ class BrokenImageServlet < WEBrick::HTTPServlet::AbstractServlet
30
30
  end
31
31
  end
32
32
 
33
+ class PurgedImageServlet < WEBrick::HTTPServlet::AbstractServlet
34
+ def do_GET(req, res)
35
+ res['Content-Type'] = "text/html"
36
+ res.code = 500
37
+ res.body = %q!<html>
38
+ <head>
39
+ <title>Pictures from Sprint: Error</title>
40
+ <link rel="STYLESHEET" type="text/css" href="/retailers/PCSNEXTEL/main.css">
41
+ </head>
42
+
43
+ <body LEFTMARGIN="0" RIGHTMARGIN="0" TOPMARGIN="0" BOTTOMMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0">
44
+ <table border="0" cellpadding="0" cellspacing="0" bgcolor="#F1F1F1" width="386">
45
+ <tr>
46
+ We're sorry, this page is not available. We apologize for the inconvenience. Please go to <a href="http://pictures.sprintpcs.com">pictures.sprintpcs.com</a> in case you are using an old bookmark, which is no longer valid.
47
+ </td>
48
+ </tr>
49
+ </table>
50
+ </body>
51
+ </html>!
52
+ end
53
+ end
54
+
33
55
  class SimpleVideoServlet < WEBrick::HTTPServlet::AbstractServlet
34
56
  def do_GET(req, res)
35
57
  res['Content-Type'] = "video/quicktime"
@@ -69,6 +91,8 @@ class Net::HTTP
69
91
  SimpleImageServlet
70
92
  when request.query['HACK'].eql?('BROKEN')
71
93
  BrokenImageServlet
94
+ when request.query['HACK'].eql?('PURGED')
95
+ PurgedImageServlet
72
96
  else
73
97
  SERVLETS[path]
74
98
  end
@@ -226,6 +250,16 @@ class MMS2R::SprintMediaTest < Test::Unit::TestCase
226
250
  mms.purge
227
251
  end
228
252
 
253
+ def test_image_should_be_purged_from_content_server
254
+ mail = TMail::Mail.parse(load_mail('sprint-purged-image-01.mail').join)
255
+ mms = MMS2R::Media.create(mail)
256
+ mms.process
257
+
258
+ assert_equal 0, mms.media.size
259
+
260
+ mms.purge
261
+ end
262
+
229
263
  def test_body_should_return_nil_when_there_is_no_user_text
230
264
  mail = TMail::Mail.parse(load_mail('sprint-image-01.mail').join)
231
265
  mms = MMS2R::Media.create(mail)
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: mms2r
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.1.11
7
- date: 2007-10-20 00:00:00 -07:00
6
+ version: 1.1.12
7
+ date: 2007-10-21 00:00:00 -07:00
8
8
  summary: Extract user media from MMS (and not carrier cruft)
9
9
  require_paths:
10
10
  - lib
@@ -120,6 +120,7 @@ files:
120
120
  - test/fixtures/sprint-broken-image-01.mail
121
121
  - test/fixtures/sprint-image-01.mail
122
122
  - test/fixtures/sprint-pcs-text-01.mail
123
+ - test/fixtures/sprint-purged-image-01.mail
123
124
  - test/fixtures/sprint-text-01.mail
124
125
  - test/fixtures/sprint-two-images-01.mail
125
126
  - test/fixtures/sprint-video-01.mail