Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -1298,30 +1298,6 @@ |
1299 | 1299 | |
1300 | 1300 | /** |
1301 | 1301 | * @todo document |
1302 | | - */ |
1303 | | -function wfQuotedPrintable( $string, $charset = '' ) { |
1304 | | - # Probably incomplete; see RFC 2045 |
1305 | | - if( empty( $charset ) ) { |
1306 | | - global $wgInputEncoding; |
1307 | | - $charset = $wgInputEncoding; |
1308 | | - } |
1309 | | - $charset = strtoupper( $charset ); |
1310 | | - $charset = str_replace( 'ISO-8859', 'ISO8859', $charset ); // ? |
1311 | | - |
1312 | | - $illegal = '\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\xff='; |
1313 | | - $replace = $illegal . '\t ?_'; |
1314 | | - if( !preg_match( "/[$illegal]/", $string ) ) { |
1315 | | - return $string; |
1316 | | - } |
1317 | | - $out = "=?$charset?Q?"; |
1318 | | - $out .= preg_replace( "/([$replace])/e", 'sprintf("=%02X",ord("$1"))', $string ); |
1319 | | - $out .= '?='; |
1320 | | - return $out; |
1321 | | -} |
1322 | | - |
1323 | | - |
1324 | | -/** |
1325 | | - * @todo document |
1326 | 1302 | * @return float |
1327 | 1303 | */ |
1328 | 1304 | function wfTime() { |
Index: trunk/phase3/includes/UserMailer.php |
— | — | @@ -58,7 +58,7 @@ |
59 | 59 | if ( $this->name != '' && !wfIsWindows() ) { |
60 | 60 | global $wgEnotifUseRealName; |
61 | 61 | $name = ( $wgEnotifUseRealName && $this->realName ) ? $this->realName : $this->name; |
62 | | - $quoted = wfQuotedPrintable( $name ); |
| 62 | + $quoted = UserMailer::quotedPrintable( $name ); |
63 | 63 | if ( strpos( $quoted, '.' ) !== false || strpos( $quoted, ',' ) !== false ) { |
64 | 64 | $quoted = '"' . $quoted . '"'; |
65 | 65 | } |
— | — | @@ -162,7 +162,7 @@ |
163 | 163 | if ( $replyto ) { |
164 | 164 | $headers['Reply-To'] = $replyto->toString(); |
165 | 165 | } |
166 | | - $headers['Subject'] = wfQuotedPrintable( $subject ); |
| 166 | + $headers['Subject'] = self::quotedPrintable( $subject ); |
167 | 167 | $headers['Date'] = date( 'r' ); |
168 | 168 | $headers['MIME-Version'] = '1.0'; |
169 | 169 | $headers['Content-type'] = ( is_null( $contentType ) ? |
— | — | @@ -225,10 +225,10 @@ |
226 | 226 | |
227 | 227 | if ( is_array( $to ) ) { |
228 | 228 | foreach ( $to as $recip ) { |
229 | | - $sent = mail( $recip->toString(), wfQuotedPrintable( $subject ), $body, $headers, $wgAdditionalMailParams ); |
| 229 | + $sent = mail( $recip->toString(), self::quotedPrintable( $subject ), $body, $headers, $wgAdditionalMailParams ); |
230 | 230 | } |
231 | 231 | } else { |
232 | | - $sent = mail( $to->toString(), wfQuotedPrintable( $subject ), $body, $headers, $wgAdditionalMailParams ); |
| 232 | + $sent = mail( $to->toString(), self::quotedPrintable( $subject ), $body, $headers, $wgAdditionalMailParams ); |
233 | 233 | } |
234 | 234 | |
235 | 235 | restore_error_handler(); |
— | — | @@ -264,6 +264,29 @@ |
265 | 265 | $phrase = strtr( $phrase, array( "\r" => '', "\n" => '', '"' => '' ) ); |
266 | 266 | return '"' . $phrase . '"'; |
267 | 267 | } |
| 268 | + |
| 269 | + /** |
| 270 | + * Converts a string into quoted-printable format |
| 271 | + */ |
| 272 | + public static function quotedPrintable( $string, $charset = '' ) { |
| 273 | + # Probably incomplete; see RFC 2045 |
| 274 | + if( empty( $charset ) ) { |
| 275 | + global $wgInputEncoding; |
| 276 | + $charset = $wgInputEncoding; |
| 277 | + } |
| 278 | + $charset = strtoupper( $charset ); |
| 279 | + $charset = str_replace( 'ISO-8859', 'ISO8859', $charset ); // ? |
| 280 | + |
| 281 | + $illegal = '\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\xff='; |
| 282 | + $replace = $illegal . '\t ?_'; |
| 283 | + if( !preg_match( "/[$illegal]/", $string ) ) { |
| 284 | + return $string; |
| 285 | + } |
| 286 | + $out = "=?$charset?Q?"; |
| 287 | + $out .= preg_replace( "/([$replace])/e", 'sprintf("=%02X",ord("$1"))', $string ); |
| 288 | + $out .= '?='; |
| 289 | + return $out; |
| 290 | + } |
268 | 291 | } |
269 | 292 | |
270 | 293 | /** |
— | — | @@ -642,4 +665,9 @@ |
643 | 666 | wfDeprecated( __FUNCTION__ ); |
644 | 667 | return UserMailer::send( $to, $from, $subject, $body, $replyto ); |
645 | 668 | } |
646 | | -/**@}*/ |
\ No newline at end of file |
| 669 | + |
| 670 | +function wfQuotedPrintable( $string, $charset = '' ) { |
| 671 | + wfDeprecated( __FUNCTION__ ); |
| 672 | + return UserMailer::quotedPrintable( $string, $charset ); |
| 673 | +} |
| 674 | +/**@}*/ |