Changeset 7041
- Timestamp:
- 04/05/2018 08:01:26 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/common/includes/slack/trac/comment-handler.php
r3087 r7041 48 48 } elseif ( 0 === strpos( $line, 'Content-Transfer-Encoding: base64' ) ) { 49 49 $base64 = true; 50 } elseif ( 0 === strpos( $line, 'Content-Type: multipart/' ) ) { 51 $multipart = true; 52 $content_type = $line; 53 54 $content_type_lines = $lines; 55 while ( $content_type_lines && ! preg_match( '/(^[\x21-\x7E][^:]+):/', current( $content_type_lines ) ) ) { 56 $content_type .= array_shift( $content_type_lines ); 57 } 58 unset( $content_type_lines ); 59 60 if ( preg_match('/boundary="?([a-zA-Z0-9\'()+_,-.\/:=?]+)"?/', $content_type, $matches ) ) { 61 $boundary = $matches[1]; 62 } 50 63 } elseif ( 0 === strpos( $line, 'Subject:' ) ) { 51 64 $subject = str_replace( 'Subject: ', '', $line ); … … 66 79 if ( ! $base64 ) { 67 80 array_shift( $lines ); 81 } 82 83 // Get the email body if multipart. 84 if ( $multipart && $boundary ) { 85 // Split content by boundary. 86 $body = implode( "\n", $lines ); 87 $body_parts = explode( '--' . $boundary, $body ); 88 array_shift( $body_parts ); // Remove empty line. 89 array_pop( $body_parts ); // Remove --. 90 91 // Assume that there's only one part and the first part is what we need. 92 $lines = explode( "\n", trim( $body_parts[0] ) ); 93 94 $base64 = false; 95 96 // Trim off headers. 97 while ( $lines && '' !== current( $lines ) ) { 98 $line = array_shift( $lines );# 99 if ( 0 === strpos( $line, 'Content-Transfer-Encoding: base64' ) ) { 100 $base64 = true; 101 } 102 } 103 104 if ( $base64 ) { 105 $lines = explode( "\n", base64_decode( implode( "\n", $lines ) ) ); 106 } 107 108 // Remove empty line between headers and body if not base64. 109 if ( ! $base64 ) { 110 array_shift( $lines ); 111 } 68 112 } 69 113
Note: See TracChangeset
for help on using the changeset viewer.