From 5f30af6674f1ec462b99ff762ba5a29d3ff3d0e5 Mon Sep 17 00:00:00 2001
From: erdgeist <>
Date: Tue, 10 Jun 2008 16:46:02 +0000
Subject: Can now decode iso-2022-jp
---
parsemail.js | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
(limited to 'parsemail.js')
diff --git a/parsemail.js b/parsemail.js
index 361716e..1a5ceb2 100644
--- a/parsemail.js
+++ b/parsemail.js
@@ -1,5 +1,5 @@
window.onload=function() {
- var url = '/'+window.location.search.substring(1);
+ var url = window.location.search.substring(1);
document.getElementById( "content" ).innerHTML = "
Fetching Mailbox... (this may take a while, please be patient...)
";
@@ -104,15 +104,15 @@ function parsemail(mail) {
myMailHeader.appendChild( textElement );
// Detect Content-Type and Content-Transfer-Encoding
- if( line.match( /Content-Type: / ) ) {
- myContentType = line.replace( /^Content-Type: (.*?);?.*$/i, "$1" );
- myContentEncoding = line.replace( /^Content-Type: .*?;.*charset=\"?(.*?)\"?(?:;|$).*/i, "$1" ).toLowerCase();
- } else if( line.match( /Content-Transfer-Encoding: /i ) ) {
- myContentTransferEncoding = line.replace( /Content-Transfer-Encoding: (.*)/i, "$1" ).toLowerCase();
+ if( line.match( /^Content-Type:/ ) ) {
+ myContentType = line.replace( /^Content-Type:\s*(.*?);?.*$/i, "$1" );
+ myContentEncoding = line.replace( /^Content-Type:\s*.*?;.*charset=\"?(.*?)\"?(?:;|$).*/i, "$1" ).toLowerCase();
+ } else if( line.match( /Content-Transfer-Encoding:/i ) ) {
+ myContentTransferEncoding = line.replace( /Content-Transfer-Encoding:\s*(.*)/i, "$1" ).toLowerCase();
}
// Check for MIME Mail
- if( line.match( /Content-Type: multipart.*boundary=.*/i ) ) {
+ if( line.match( /Content-Type:\s*multipart.*boundary=.*/i ) ) {
myState = myStates.inMultiPartMailHeader;
multiPartDivider = line.replace( /.*boundary=\"?(.*?)\"?$/gi, "--$1" );
}
@@ -201,11 +201,11 @@ function parsemail(mail) {
// Header lines may contain encoded words
line = decode_header( line );
- if( line.match( /Content-Type: / ) ) {
- myMultiContentType = line.replace( /Content-Type: (.*?);.*/, "$1" ).toLowerCase();
- myMultiContentEncoding = line.replace( /Content-Type: .*?;.*charset=\"?(.*?)\"?(?:;|$).*/i, "$1" ).toLowerCase();
- } else if( line.match( /Content-Transfer-Encoding: /i ) ) {
- myMultiContentTransferEncoding = line.replace( /Content-Transfer-Encoding: (.*?)/, "$1" ).toLowerCase();
+ if( line.match( /Content-Type:/ ) ) {
+ myMultiContentType = line.replace( /Content-Type:\s*(.*?);.*/, "$1" ).toLowerCase();
+ myMultiContentEncoding = line.replace( /Content-Type:\s*.*?;.*charset=\"?(.*?)\"?(?:;|$).*/i, "$1" ).toLowerCase();
+ } else if( line.match( /Content-Transfer-Encoding:/i ) ) {
+ myMultiContentTransferEncoding = line.replace( /Content-Transfer-Encoding:\s*(.*?)/, "$1" ).toLowerCase();
}
if( line.match( /.*name=/ ) ) {
--
cgit v1.2.3