mms2r 3.3.1 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gemtest +0 -0
- data/Gemfile +11 -11
- data/Gemfile.lock +28 -24
- data/History.txt +7 -0
- data/Manifest.txt +5 -4
- data/README.txt +8 -5
- data/conf/1nbox.net.yml +4 -4
- data/conf/aliases.yml +1 -1
- data/conf/mediamessaging.o2.co.uk.yml +1 -1
- data/conf/messaging.nextel.com.yml +8 -8
- data/conf/mms.3ireland.ie.yml +8 -8
- data/conf/mms.ae.yml +1 -1
- data/conf/mms.alltel.com.yml +2 -2
- data/conf/mms.att.net.yml +9 -9
- data/conf/mms.dobson.net.yml +3 -3
- data/conf/mms.luxgsm.lu.yml +8 -8
- data/conf/mms.mobileiam.ma.yml +6 -6
- data/conf/mms.mtn.co.za.yml +4 -4
- data/conf/mms.myhelio.com.yml +7 -7
- data/conf/mms.netcom.no.yml +2 -2
- data/conf/mms.o2online.de.yml +6 -6
- data/conf/mms.three.co.uk.yml +9 -9
- data/conf/mms.uscc.net.mail +6 -6
- data/conf/mms.vodacom4me.co.za.yml +4 -4
- data/conf/mms2r_media.yml +20 -20
- data/conf/mobile.indosat.net.id.yml +4 -4
- data/conf/msg.telus.com.yml +2 -2
- data/conf/orangemms.net.yml +7 -7
- data/conf/pm.sprint.com.yml +8 -8
- data/conf/pxt.vodafone.net.nz.yml +3 -3
- data/conf/rci.rogers.com.yml +7 -7
- data/conf/sms.sasktel.com.yml +9 -9
- data/conf/tmomail.net.yml +22 -22
- data/conf/txt.bell.ca.yml +2 -2
- data/conf/unicel.com.yml +3 -3
- data/conf/vmpix.com.yml +7 -7
- data/conf/vzwpix.com.yml +6 -6
- data/conf/waw.plspictures.com.yml +8 -9
- data/dev_tools/anonymizer.rb +1 -1
- data/lib/{mail_ext.rb → ext/mail.rb} +0 -0
- data/lib/ext/object.rb +11 -0
- data/lib/mms2r.rb +10 -20
- data/lib/mms2r/media.rb +33 -29
- data/mms2r.gemspec +23 -43
- data/test/fixtures/ad_new.txt +5 -0
- data/test/fixtures/dici_un_mois_georgie.txt +1 -0
- data/test/hax.rb +8 -0
- data/test/test_1nbox_net.rb +2 -2
- data/test/test_bell_canada.rb +1 -1
- data/test/test_bellsouth_net.rb +2 -2
- data/test/test_helper.rb +5 -9
- data/test/test_mediamessaging_o2_co_uk.rb +1 -1
- data/test/test_messaging_nextel_com.rb +1 -1
- data/test/test_messaging_sprintpcs_com.rb +1 -1
- data/test/test_mms2r_media.rb +35 -23
- data/test/test_mms_3ireland_ie.rb +1 -1
- data/test/test_mms_ae.rb +1 -1
- data/test/test_mms_alltel_com.rb +1 -1
- data/test/test_mms_att_net.rb +2 -2
- data/test/test_mms_dobson_net.rb +1 -1
- data/test/test_mms_luxgsm_lu.rb +1 -1
- data/test/test_mms_mobileiam_ma.rb +1 -1
- data/test/test_mms_mtn_co_za.rb +1 -1
- data/test/test_mms_mycricket_com.rb +1 -1
- data/test/test_mms_myhelio_com.rb +1 -1
- data/test/test_mms_netcom_no.rb +1 -1
- data/test/test_mms_o2online_de.rb +1 -1
- data/test/test_mms_three_co_uk.rb +1 -1
- data/test/test_mms_uscc_net.rb +1 -1
- data/test/test_mms_vodacom4me_co_za.rb +1 -1
- data/test/test_mobile_indosat_net_id.rb +1 -1
- data/test/test_msg_telus_com.rb +1 -1
- data/test/test_orangemms_net.rb +1 -1
- data/test/test_pm_sprint_com.rb +1 -1
- data/test/test_pxt_vodafone_net_nz.rb +1 -1
- data/test/test_rci_rogers_com.rb +1 -1
- data/test/test_sms_sasktel_com.rb +1 -1
- data/test/test_tmomail_net.rb +4 -4
- data/test/test_unicel_com.rb +1 -1
- data/test/test_vmpix_com.rb +1 -1
- data/test/test_vzwpix_com.rb +3 -7
- data/test/test_waw_plspictures_com.rb +1 -1
- metadata +91 -118
- data/.gitignore +0 -7
- data/dev_tools/github.rb +0 -8
- data/test/test_github.rb +0 -12
data/conf/mms.uscc.net.mail
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
ignore:
|
|
3
|
-
text/plain:
|
|
4
|
-
- /\AThank you for using Picture and Video Messaging by U\.S\. Cellular.*/m
|
|
5
|
-
transform:
|
|
6
|
-
text/plain:
|
|
7
|
-
- - /\A(.+?)\s+Thank you for using Picture and Video Messaging by U\.S\. Cellular.*/m
|
|
8
|
-
- "
|
|
3
|
+
text/plain:
|
|
4
|
+
- !ruby/regexp /\AThank you for using Picture and Video Messaging by U\.S\. Cellular.*/m
|
|
5
|
+
transform:
|
|
6
|
+
text/plain:
|
|
7
|
+
- - !ruby/regexp /\A(.+?)\s+Thank you for using Picture and Video Messaging by U\.S\. Cellular.*/m
|
|
8
|
+
- "\\1"
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
ignore:
|
|
3
3
|
text/html:
|
|
4
|
-
- /.*You have an <b>MMS<\/b> message!.*/m
|
|
4
|
+
- !ruby/regexp /.*You have an <b>MMS<\/b> message!.*/m
|
|
5
5
|
transform:
|
|
6
6
|
text/plain:
|
|
7
|
-
- - /\s*This is an MMS message brought to you by Vodacom\. Click here to view online presentation http:\/\/mms.vodacom4me.co.za\/.*$/
|
|
7
|
+
- - !ruby/regexp /\s*This is an MMS message brought to you by Vodacom\. Click here to view online presentation http:\/\/mms.vodacom4me.co.za\/.*$/
|
|
8
8
|
- ""
|
|
9
9
|
number:
|
|
10
10
|
- from
|
|
11
|
-
- /^([^\s]+)\s.*/
|
|
12
|
-
- "
|
|
11
|
+
- !ruby/regexp /^([^\s]+)\s.*/
|
|
12
|
+
- "\\1"
|
|
13
13
|
|
data/conf/mms2r_media.yml
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
---
|
|
2
2
|
ignore:
|
|
3
3
|
text/plain:
|
|
4
|
-
- /^\(no subject\)$/i
|
|
5
|
-
- /\ASent via BlackBerry (from|by) .*$/im
|
|
6
|
-
- /\ASent from my Verizon Wireless BlackBerry$/im
|
|
7
|
-
- /\ASent from (my|your) iPhone.?$/im
|
|
8
|
-
- /\ASent on the Sprint.* Now Network.*$/im
|
|
4
|
+
- !ruby/regexp /^\(no subject\)$/i
|
|
5
|
+
- !ruby/regexp /\ASent via BlackBerry (from|by) .*$/im
|
|
6
|
+
- !ruby/regexp /\ASent from my Verizon Wireless BlackBerry$/im
|
|
7
|
+
- !ruby/regexp /\ASent from (my|your) iPhone.?$/im
|
|
8
|
+
- !ruby/regexp /\ASent on the Sprint.* Now Network.*$/im
|
|
9
9
|
multipart/mixed:
|
|
10
|
-
- "/^Attachment: /i"
|
|
11
|
-
transform:
|
|
12
|
-
text/plain:
|
|
13
|
-
- - /\A(.*?)Sent via BlackBerry (from|by) .*$/im
|
|
14
|
-
- "
|
|
15
|
-
- - /\A(.*?)Sent from my Verizon Wireless BlackBerry$/im
|
|
16
|
-
- "
|
|
17
|
-
- - /\A(.*?)Sent from (my|your) iPhone.?$/im
|
|
18
|
-
- "
|
|
19
|
-
- - /\A(.*?)\s+image\/jpeg$/im
|
|
20
|
-
- "
|
|
21
|
-
- - /\A(.*?)Sent on the Sprint.* Now Network.*$/im
|
|
22
|
-
- "
|
|
23
|
-
device_types:
|
|
10
|
+
- !ruby/regexp "/^Attachment: /i"
|
|
11
|
+
transform:
|
|
12
|
+
text/plain:
|
|
13
|
+
- - !ruby/regexp /\A(.*?)Sent via BlackBerry (from|by) .*$/im
|
|
14
|
+
- "\\1"
|
|
15
|
+
- - !ruby/regexp /\A(.*?)Sent from my Verizon Wireless BlackBerry$/im
|
|
16
|
+
- "\\1"
|
|
17
|
+
- - !ruby/regexp /\A(.*?)Sent from (my|your) iPhone.?$/im
|
|
18
|
+
- "\\1"
|
|
19
|
+
- - !ruby/regexp /\A(.*?)\s+image\/jpeg$/im
|
|
20
|
+
- "\\1"
|
|
21
|
+
- - !ruby/regexp /\A(.*?)Sent on the Sprint.* Now Network.*$/im
|
|
22
|
+
- "\\1"
|
|
23
|
+
device_types:
|
|
24
24
|
headers:
|
|
25
25
|
x-mailer:
|
|
26
26
|
:iphone: !ruby/regexp /iPhone Mail/i
|
|
@@ -29,7 +29,7 @@ device_types:
|
|
|
29
29
|
:iphone: !ruby/regexp /iPhone Mail/i
|
|
30
30
|
x-rim-org-msg-ref-id:
|
|
31
31
|
:blackberry: !ruby/regexp /.+/
|
|
32
|
-
# TODO do something about the assortment of camera models that have
|
|
32
|
+
# TODO do something about the assortment of camera models that have
|
|
33
33
|
# been seen:
|
|
34
34
|
# 1.3 Megapixel, 2.0 Megapixel, BlackBerry, CU920, G'z One TYPE-S,
|
|
35
35
|
# Hermes, iPhone, LG8700, LSI_S5K4AAFA, Micron MT9M113 1.3MP YUV,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
ignore:
|
|
3
3
|
text/plain:
|
|
4
|
-
- /\A\.\z/im
|
|
4
|
+
- !ruby/regexp /\A\.\z/im
|
|
5
5
|
- .
|
|
6
6
|
text/html:
|
|
7
|
-
- /I-Memova - Email Praktis. Cara Taktis. Powered by IM2./i
|
|
7
|
+
- !ruby/regexp /I-Memova - Email Praktis. Cara Taktis. Powered by IM2./i
|
|
8
8
|
image/jpeg:
|
|
9
9
|
- cp__newBanner.jpg
|
|
10
10
|
number:
|
|
11
11
|
- return-path
|
|
12
|
-
- /^([^@]+)@.*/
|
|
13
|
-
- "
|
|
12
|
+
- !ruby/regexp /^([^@]+)@.*/
|
|
13
|
+
- "\\1"
|
|
14
14
|
|
data/conf/msg.telus.com.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
ignore:
|
|
3
3
|
text/plain:
|
|
4
|
-
- /This is an MMS message. Please go to http/m
|
|
4
|
+
- !ruby/regexp /This is an MMS message. Please go to http/m
|
|
5
5
|
text/html:
|
|
6
|
-
- /You've received a Message from a TELUS phone./m
|
|
6
|
+
- !ruby/regexp /You've received a Message from a TELUS phone./m
|
data/conf/orangemms.net.yml
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
ignore:
|
|
3
3
|
application/smil:
|
|
4
|
-
- /\A<smil><head><layout><root-layout height=/m
|
|
5
|
-
text/plain:
|
|
4
|
+
- !ruby/regexp /\A<smil><head><layout><root-layout height=/m
|
|
5
|
+
text/plain:
|
|
6
6
|
- banniere.txt
|
|
7
|
-
- /\A--\s+This Orange Multi Media Message was sent wirefree from an Orange MMS.*/mi
|
|
8
|
-
transform:
|
|
9
|
-
text/plain:
|
|
10
|
-
- - /^Orange UK MMS$/i
|
|
7
|
+
- !ruby/regexp /\A--\s+This Orange Multi Media Message was sent wirefree from an Orange MMS.*/mi
|
|
8
|
+
transform:
|
|
9
|
+
text/plain:
|
|
10
|
+
- - !ruby/regexp /^Orange UK MMS$/i
|
|
11
11
|
- ""
|
|
12
|
-
- - /^Wiadomo
|
|
12
|
+
- - !ruby/regexp /^Wiadomo.* multimedialna\.$/i
|
|
13
13
|
- ""
|
data/conf/pm.sprint.com.yml
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
ignore:
|
|
3
3
|
text/html:
|
|
4
|
-
- /We're sorry, this page is not available. We apologize for the inconvenience./mi
|
|
5
|
-
text/plain:
|
|
6
|
-
- /You have new [Picture|Video] Mail!\s+Click Go\/View to see now./mi
|
|
7
|
-
transform:
|
|
8
|
-
text/plain:
|
|
9
|
-
- - /^You have new Picture Mail!$/i
|
|
4
|
+
- !ruby/regexp /We're sorry, this page is not available. We apologize for the inconvenience./mi
|
|
5
|
+
text/plain:
|
|
6
|
+
- !ruby/regexp /You have new [Picture|Video] Mail!\s+Click Go\/View to see now./mi
|
|
7
|
+
transform:
|
|
8
|
+
text/plain:
|
|
9
|
+
- - !ruby/regexp /^You have new Picture Mail!$/i
|
|
10
10
|
- ""
|
|
11
|
-
- - /^New Message$/i
|
|
11
|
+
- - !ruby/regexp /^New Message$/i
|
|
12
12
|
- ""
|
|
13
|
-
- - /^PictureMail$/i
|
|
13
|
+
- - !ruby/regexp /^PictureMail$/i
|
|
14
14
|
- ""
|
data/conf/rci.rogers.com.yml
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
---
|
|
2
2
|
ignore:
|
|
3
3
|
image/gif:
|
|
4
|
-
- /^.*$/i
|
|
4
|
+
- !ruby/regexp /^.*$/i
|
|
5
5
|
text/plain:
|
|
6
|
-
- /^Uve received a video or picture msg from .*/im
|
|
6
|
+
- !ruby/regexp /^Uve received a video or picture msg from .*/im
|
|
7
7
|
text/html:
|
|
8
|
-
- /Picture from your Rogers Wireless friend/im
|
|
8
|
+
- !ruby/regexp /Picture from your Rogers Wireless friend/im
|
|
9
9
|
|
|
10
10
|
transform:
|
|
11
|
-
text/plain:
|
|
12
|
-
- - /^You have received a Picture Message from your Rogers Wireless.*/i
|
|
11
|
+
text/plain:
|
|
12
|
+
- - !ruby/regexp /^You have received a Picture Message from your Rogers Wireless.*/i
|
|
13
13
|
- ""
|
|
14
14
|
|
|
15
15
|
number:
|
|
16
16
|
- from
|
|
17
|
-
- /^([
|
|
18
|
-
- "
|
|
17
|
+
- !ruby/regexp /^([^\/@]+).*/
|
|
18
|
+
- "\\1"
|
data/conf/sms.sasktel.com.yml
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
ignore:
|
|
3
|
-
text/html:
|
|
4
|
-
- /.*/im
|
|
5
|
-
text/plain:
|
|
6
|
-
- /^You have received a New Message/i
|
|
7
|
-
image/gif:
|
|
8
|
-
- /.*/im
|
|
9
|
-
transform:
|
|
10
|
-
text/plain:
|
|
11
|
-
- - /^A Picture\/Video Message!$/i
|
|
3
|
+
text/html:
|
|
4
|
+
- !ruby/regexp /.*/im
|
|
5
|
+
text/plain:
|
|
6
|
+
- !ruby/regexp /^You have received a New Message/i
|
|
7
|
+
image/gif:
|
|
8
|
+
- !ruby/regexp /.*/im
|
|
9
|
+
transform:
|
|
10
|
+
text/plain:
|
|
11
|
+
- - !ruby/regexp /^A Picture\/Video Message!$/i
|
|
12
12
|
- ""
|
data/conf/tmomail.net.yml
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
---
|
|
2
2
|
ignore:
|
|
3
|
-
image/jpeg:
|
|
4
|
-
- /^masthead.jpg$/i
|
|
5
|
-
- /^logo.jpg$/i
|
|
6
|
-
image/gif:
|
|
7
|
-
- /^dottedline350.gif$/i
|
|
8
|
-
- /^dottedline600.gif$/i
|
|
9
|
-
- /^dottedLine_350.gif$/i
|
|
10
|
-
- /^dottedLine_600.gif$/i
|
|
11
|
-
- /^spacer.gif$/i
|
|
12
|
-
- /^video.gif$/i
|
|
13
|
-
- /^audio.gif$/i
|
|
14
|
-
- /^tmobilelogo.gif$/i
|
|
15
|
-
- /^tmobilespace.gif$/i
|
|
16
|
-
text/html:
|
|
17
|
-
- /<html>\s+<head>\s+<title>T-Mobile<\/title>/m
|
|
18
|
-
- /<title>MMS E-Mail<\/title>/m
|
|
3
|
+
image/jpeg:
|
|
4
|
+
- !ruby/regexp /^masthead.jpg$/i
|
|
5
|
+
- !ruby/regexp /^logo.jpg$/i
|
|
6
|
+
image/gif:
|
|
7
|
+
- !ruby/regexp /^dottedline350.gif$/i
|
|
8
|
+
- !ruby/regexp /^dottedline600.gif$/i
|
|
9
|
+
- !ruby/regexp /^dottedLine_350.gif$/i
|
|
10
|
+
- !ruby/regexp /^dottedLine_600.gif$/i
|
|
11
|
+
- !ruby/regexp /^spacer.gif$/i
|
|
12
|
+
- !ruby/regexp /^video.gif$/i
|
|
13
|
+
- !ruby/regexp /^audio.gif$/i
|
|
14
|
+
- !ruby/regexp /^tmobilelogo.gif$/i
|
|
15
|
+
- !ruby/regexp /^tmobilespace.gif$/i
|
|
16
|
+
text/html:
|
|
17
|
+
- !ruby/regexp /<html>\s+<head>\s+<title>T-Mobile<\/title>/m
|
|
18
|
+
- !ruby/regexp /<title>MMS E-Mail<\/title>/m
|
|
19
19
|
|
|
20
20
|
number:
|
|
21
21
|
- from
|
|
22
|
-
- /^"?([
|
|
23
|
-
- "
|
|
22
|
+
- !ruby/regexp /^"?([^\/@]+).*/
|
|
23
|
+
- "\\1"
|
|
24
24
|
|
|
25
|
-
transform:
|
|
26
|
-
text/plain:
|
|
27
|
-
- - /.*\s+Text:\s+(.*?)\s+-+\s.*/im
|
|
28
|
-
- "
|
|
25
|
+
transform:
|
|
26
|
+
text/plain:
|
|
27
|
+
- - !ruby/regexp /.*\s+Text:\s+(.*?)\s+-+\s.*/im
|
|
28
|
+
- "\\1"
|
data/conf/txt.bell.ca.yml
CHANGED
data/conf/unicel.com.yml
CHANGED
data/conf/vmpix.com.yml
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
ignore:
|
|
3
3
|
text/html:
|
|
4
|
-
- /This message is from\s+a Virgin Mobile user. Enjoy./mi
|
|
5
|
-
text/plain:
|
|
6
|
-
- /^This is an MMS message\.$/i
|
|
4
|
+
- !ruby/regexp /This message is from\s+a Virgin Mobile user. Enjoy./mi
|
|
5
|
+
text/plain:
|
|
6
|
+
- !ruby/regexp /^This is an MMS message\.$/i
|
|
7
7
|
|
|
8
|
-
transform:
|
|
9
|
-
text/plain:
|
|
10
|
-
- - /(.*?)-+\s+Sent by Text Messaging from a mobile device.*/im
|
|
11
|
-
- "
|
|
8
|
+
transform:
|
|
9
|
+
text/plain:
|
|
10
|
+
- - !ruby/regexp /(.*?)-+\s+Sent by Text Messaging from a mobile device.*/im
|
|
11
|
+
- "\\1"
|
data/conf/vzwpix.com.yml
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
ignore:
|
|
3
|
-
text/plain:
|
|
4
|
-
- /\AThis message (was|has been) sent using .* from Verizon Wireless!.*/m
|
|
5
|
-
transform:
|
|
6
|
-
text/plain:
|
|
7
|
-
- - /\A(.+?)\s+This message (was|has been) sent using .* from Verizon Wireless!.*/m
|
|
8
|
-
- "
|
|
3
|
+
text/plain:
|
|
4
|
+
- !ruby/regexp /\AThis message (was|has been) sent using .* from Verizon Wireless!.*/m
|
|
5
|
+
transform:
|
|
6
|
+
text/plain:
|
|
7
|
+
- - !ruby/regexp /\A(.+?)\s+This message (was|has been) sent using .* from Verizon Wireless!.*/m
|
|
8
|
+
- "\\1"
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
---
|
|
2
|
-
transform:
|
|
3
|
-
text/plain:
|
|
4
|
-
- - /^You have received a Multimedia Message$/i
|
|
2
|
+
transform:
|
|
3
|
+
text/plain:
|
|
4
|
+
- - !ruby/regexp /^You have received a Multimedia Message$/i
|
|
5
5
|
- ""
|
|
6
6
|
number:
|
|
7
7
|
- return-path
|
|
8
|
-
- /^([^@]+)@.*/
|
|
9
|
-
- "
|
|
8
|
+
- !ruby/regexp /^([^@]+)@.*/
|
|
9
|
+
- "\\1"
|
|
10
10
|
ignore:
|
|
11
|
-
text/html:
|
|
12
|
-
- /.*/m
|
|
11
|
+
text/html:
|
|
12
|
+
- !ruby/regexp /.*/m
|
|
13
13
|
text/plain:
|
|
14
|
-
- /\AA New Photo\/Video Message.\s+Click Go\/View to see now http/im
|
|
15
|
-
|
|
14
|
+
- !ruby/regexp /\AA New Photo\/Video Message.\s+Click Go\/View to see now http/im
|
data/dev_tools/anonymizer.rb
CHANGED
|
File without changes
|
data/lib/ext/object.rb
ADDED
data/lib/mms2r.rb
CHANGED
|
@@ -39,7 +39,7 @@ module MMS2R
|
|
|
39
39
|
##
|
|
40
40
|
# MMS2R library version
|
|
41
41
|
|
|
42
|
-
VERSION = '3.
|
|
42
|
+
VERSION = '3.4.0'
|
|
43
43
|
|
|
44
44
|
end
|
|
45
45
|
|
|
@@ -52,23 +52,8 @@ module MMS2R
|
|
|
52
52
|
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
class Object
|
|
57
|
-
def blank?
|
|
58
|
-
if respond_to?(:empty?) && respond_to?(:strip)
|
|
59
|
-
empty? or strip.empty?
|
|
60
|
-
elsif respond_to?(:empty?)
|
|
61
|
-
empty?
|
|
62
|
-
else
|
|
63
|
-
!self
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
%W{ mail fileutils pathname tmpdir yaml uuidtools iconv exifr }.each do |g|
|
|
55
|
+
%W{ yaml mail fileutils pathname tmpdir yaml digest/sha1 iconv exifr }.each do |g|
|
|
70
56
|
begin
|
|
71
|
-
gem 'mail', '= 2.2.13' if g == 'mail'
|
|
72
57
|
require g
|
|
73
58
|
rescue LoadError
|
|
74
59
|
require 'rubygems'
|
|
@@ -76,7 +61,12 @@ end
|
|
|
76
61
|
end
|
|
77
62
|
end
|
|
78
63
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
64
|
+
# HAX to not deal with Psych YAML parser in Ruby >= 1.9
|
|
65
|
+
#YAML::ENGINE.yamler= 'syck' if defined?(YAML::ENGINE)
|
|
66
|
+
|
|
67
|
+
require File.join(File.dirname(__FILE__), 'ext/mail')
|
|
68
|
+
require File.join(File.dirname(__FILE__), 'ext/object')
|
|
69
|
+
require File.join(File.dirname(__FILE__), 'mms2r/media')
|
|
70
|
+
require File.join(File.dirname(__FILE__), 'mms2r/media/sprint')
|
|
71
|
+
|
|
82
72
|
MMS2R.register('pm.sprint.com', MMS2R::Media::Sprint)
|
data/lib/mms2r/media.rb
CHANGED
|
@@ -64,15 +64,15 @@
|
|
|
64
64
|
# The root hash itself has two hashes under the keys 'ignore' and 'transform',
|
|
65
65
|
# and an array under the 'number' key.
|
|
66
66
|
# Each hash is itself keyed by mime-type. The value pointed to by the mime-type
|
|
67
|
-
# key is an array. The ignore arrays are first
|
|
68
|
-
#
|
|
69
|
-
#
|
|
70
|
-
#
|
|
71
|
-
#
|
|
72
|
-
#
|
|
67
|
+
# key is an array. The ignore arrays are first inspected as regular expressions
|
|
68
|
+
# else are used as a equality for a string filename. Ignores # work by filename
|
|
69
|
+
# for the multi-part of the MMS that is being inspected. The array pointed to
|
|
70
|
+
# by the 'number' key represents an alternate mail header where the sender's
|
|
71
|
+
# number can be found with a regular expression and replacement value for a
|
|
72
|
+
# gsub.
|
|
73
73
|
#
|
|
74
74
|
# The transform arrays are themselves an array of two element arrays. The elements
|
|
75
|
-
# are parameters for gsub
|
|
75
|
+
# are regexp parameters for gsub.
|
|
76
76
|
#
|
|
77
77
|
# Ignore instructions are honored first then transform instructions. In the sample,
|
|
78
78
|
# masthead.jpg is ignored as a regular expression, and spacer.gif is ignored as a
|
|
@@ -159,7 +159,7 @@ module MMS2R
|
|
|
159
159
|
end
|
|
160
160
|
|
|
161
161
|
f = File.expand_path(File.join(self.conf_dir(), "from.yml"))
|
|
162
|
-
from = YAML::load_file(f)
|
|
162
|
+
from = YAML::load_file(f)
|
|
163
163
|
|
|
164
164
|
ret = case
|
|
165
165
|
when from.include?(from_domain)
|
|
@@ -190,9 +190,10 @@ module MMS2R
|
|
|
190
190
|
log("#{self.class} created", :info)
|
|
191
191
|
@carrier = self.class.domain(mail)
|
|
192
192
|
@dir_count = 0
|
|
193
|
+
sha = Digest::SHA1.hexdigest("#{@carrier}-#{Time.now.to_i}-#{rand}")
|
|
193
194
|
@media_dir = File.expand_path(
|
|
194
195
|
File.join(self.tmp_dir(),
|
|
195
|
-
"#{self.safe_message_id(@mail.message_id)}_#{
|
|
196
|
+
"#{self.safe_message_id(@mail.message_id)}_#{sha}"))
|
|
196
197
|
@media = {}
|
|
197
198
|
@was_processed = false
|
|
198
199
|
@number = nil
|
|
@@ -204,11 +205,11 @@ module MMS2R
|
|
|
204
205
|
@default_html = nil
|
|
205
206
|
|
|
206
207
|
f = File.expand_path(File.join(self.conf_dir(), "aliases.yml"))
|
|
207
|
-
@aliases = YAML::load_file(f)
|
|
208
|
+
@aliases = YAML::load_file(f)
|
|
208
209
|
|
|
209
210
|
conf = "#{@aliases[@carrier] || @carrier}.yml"
|
|
210
211
|
f = File.expand_path(File.join(self.conf_dir(), conf))
|
|
211
|
-
c = YAML::load_file(f)
|
|
212
|
+
c = File.exist?(f) ? YAML::load_file(f) : {}
|
|
212
213
|
@config = self.class.initialize_config(c)
|
|
213
214
|
|
|
214
215
|
processor_module = MMS2R::CARRIERS[@carrier]
|
|
@@ -228,7 +229,7 @@ module MMS2R
|
|
|
228
229
|
unless @number
|
|
229
230
|
params = config['number']
|
|
230
231
|
if params && params.any? && (header = mail.header[params[0]])
|
|
231
|
-
@number = header.to_s.gsub(
|
|
232
|
+
@number = header.to_s.gsub(params[1], params[2])
|
|
232
233
|
end
|
|
233
234
|
if @number.nil? || @number.blank?
|
|
234
235
|
@number = mail.from.first.split(/@|\//).first rescue ""
|
|
@@ -383,8 +384,8 @@ module MMS2R
|
|
|
383
384
|
def ignore_media?(type, part)
|
|
384
385
|
ignores = config['ignore'][type] || []
|
|
385
386
|
ignore = ignores.detect{ |test| filename?(part) == test}
|
|
386
|
-
ignore ||= ignores.detect{ |test| filename?(part) =~
|
|
387
|
-
ignore ||= ignores.detect{ |test| part.body.decoded.strip =~
|
|
387
|
+
ignore ||= ignores.detect{ |test| filename?(part) =~ test if test.is_a?(Regexp) }
|
|
388
|
+
ignore ||= ignores.detect{ |test| part.body.decoded.strip =~ test if test.is_a?(Regexp) }
|
|
388
389
|
ignore ||= (part.body.decoded.strip.size == 0 ? true : nil)
|
|
389
390
|
ignore.nil? ? false : true
|
|
390
391
|
end
|
|
@@ -408,7 +409,7 @@ module MMS2R
|
|
|
408
409
|
if part.part_type? =~ /^text\// ||
|
|
409
410
|
part.part_type? == 'application/smil'
|
|
410
411
|
type, content = transform_text_part(part)
|
|
411
|
-
mode = '
|
|
412
|
+
mode = 'wb'
|
|
412
413
|
else
|
|
413
414
|
if part.part_type? == 'application/octet-stream'
|
|
414
415
|
type = type_from_filename(filename?(part))
|
|
@@ -431,22 +432,25 @@ module MMS2R
|
|
|
431
432
|
# configuration.
|
|
432
433
|
|
|
433
434
|
def transform_text(type, text, original_encoding = 'ISO-8859-1')
|
|
434
|
-
|
|
435
435
|
return type, text if !config['transform'] || !(transforms = config['transform'][type])
|
|
436
436
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
437
|
+
if RUBY_VERSION < "1.9"
|
|
438
|
+
#convert to UTF-8
|
|
439
|
+
begin
|
|
440
|
+
c = Iconv.new('UTF-8', original_encoding )
|
|
441
|
+
utf_t = c.iconv(text)
|
|
442
|
+
rescue Exception => e
|
|
443
|
+
utf_t = text
|
|
444
|
+
end
|
|
445
|
+
else
|
|
446
|
+
utf_t = text.encoding == "ASCII-8BIT" ? text.force_encoding("ISO-8859-1").encode("UTF-8") : text
|
|
443
447
|
end
|
|
444
448
|
|
|
445
449
|
transforms.each do |transform|
|
|
446
450
|
next unless transform.size == 2
|
|
447
451
|
p = transform.first
|
|
448
452
|
r = transform.last
|
|
449
|
-
utf_t = utf_t.gsub(
|
|
453
|
+
utf_t = utf_t.gsub(p, r) rescue utf_t
|
|
450
454
|
end
|
|
451
455
|
|
|
452
456
|
return type, utf_t
|
|
@@ -509,13 +513,13 @@ module MMS2R
|
|
|
509
513
|
def filename?(part)
|
|
510
514
|
name = part.filename
|
|
511
515
|
if (name.nil? || name.empty?)
|
|
512
|
-
if part.content_id &&
|
|
513
|
-
name =
|
|
516
|
+
if part.content_id && (matched = /^<(.+)>$/.match(part.content_id))
|
|
517
|
+
name = matched[1]
|
|
514
518
|
else
|
|
515
519
|
name = "#{Time.now.to_f}.#{self.default_ext(part.part_type?)}"
|
|
516
520
|
end
|
|
517
521
|
end
|
|
518
|
-
#
|
|
522
|
+
# FIXME FWIW, janky look for dot extension 1 to 4 chars long
|
|
519
523
|
name = (name =~ /\..{1,4}$/ ? name : "#{name}.#{self.default_ext(part.part_type?)}").strip
|
|
520
524
|
|
|
521
525
|
# handle excessively large filenames
|
|
@@ -649,7 +653,7 @@ module MMS2R
|
|
|
649
653
|
|
|
650
654
|
def self.initialize_config(c)
|
|
651
655
|
f = File.expand_path(File.join(self.conf_dir(), "mms2r_media.yml"))
|
|
652
|
-
conf = YAML::load_file(f)
|
|
656
|
+
conf = YAML::load_file(f)
|
|
653
657
|
conf['ignore'] ||= {} unless conf['ignore']
|
|
654
658
|
conf['transform'] = {} unless conf['transform']
|
|
655
659
|
conf['number'] = [] unless conf['number']
|
|
@@ -753,8 +757,8 @@ module MMS2R
|
|
|
753
757
|
if File.size(path) > size
|
|
754
758
|
size = File.size(path)
|
|
755
759
|
file = File.new(path)
|
|
756
|
-
media.each do |type,
|
|
757
|
-
mime_type = type if
|
|
760
|
+
media.each do |type,_files|
|
|
761
|
+
mime_type = type if _files.detect{ |_path| _path == path }
|
|
758
762
|
end
|
|
759
763
|
end
|
|
760
764
|
end
|