Changeset 2e6825b in github


Ignore:
Timestamp:
Sep 5, 2008 5:55:07 AM (5 years ago)
Author:
thomascube <thomas@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
be5f03b
Parents:
a6d7a9f
Message:

Applied mime_decode patch by David Lublink

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    rc505e59 r2e6825b  
    66- Enable export of address book contacts as vCard 
    77- Respect Content-Location headers in multipart/related messages according to RFC2110 (#1484946) 
     8- Applied mime_decode patch by David Lublink 
    89 
    9102008/09/04 (alec) 
  • program/include/rcube_imap.php

    rc505e59 r2e6825b  
    24172417  function decode_mime_string($input, $fallback=null) 
    24182418    { 
     2419    // Initialize variable 
    24192420    $out = ''; 
    24202421 
    2421     $pos = strpos($input, '=?'); 
    2422     if ($pos !== false) 
    2423       { 
    2424       // rfc: all line breaks or other characters not found  
    2425       // in the Base64 Alphabet must be ignored by decoding software 
    2426       // delete all blanks between MIME-lines, differently we can  
    2427       // receive unnecessary blanks and broken utf-8 symbols 
    2428       $input = preg_replace("/\?=\s+=\?/", '?==?', $input); 
    2429  
    2430       $out = substr($input, 0, $pos); 
    2431    
    2432       $end_cs_pos = strpos($input, "?", $pos+2); 
    2433       $end_en_pos = strpos($input, "?", $end_cs_pos+1); 
    2434       $end_pos = strpos($input, "?=", $end_en_pos+1); 
    2435    
    2436       $encstr = substr($input, $pos+2, ($end_pos-$pos-2)); 
    2437       $rest = substr($input, $end_pos+2); 
    2438  
    2439       $out .= rcube_imap::_decode_mime_string_part($encstr); 
    2440       $out .= rcube_imap::decode_mime_string($rest, $fallback); 
    2441  
     2422    // Iterate instead of recursing, this way if there are too many values we don't have stack overflows 
     2423    // rfc: all line breaks or other characters not found  
     2424    // in the Base64 Alphabet must be ignored by decoding software 
     2425    // delete all blanks between MIME-lines, differently we can  
     2426    // receive unnecessary blanks and broken utf-8 symbols 
     2427    $input = preg_replace("/\?=\s+=\?/", '?==?', $input); 
     2428 
     2429    // Check if there is stuff to decode 
     2430    if (strpos($input, '=?') !== false) { 
     2431      // Loop through the string to decode all occurences of =? ?= into the variable $out  
     2432      while(($pos = strpos($input, '=?')) !== false) { 
     2433        // Append everything that is before the text to be decoded 
     2434        $out .= substr($input, 0, $pos); 
     2435 
     2436        // Get the location of the text to decode 
     2437        $end_cs_pos = strpos($input, "?", $pos+2); 
     2438        $end_en_pos = strpos($input, "?", $end_cs_pos+1); 
     2439        $end_pos = strpos($input, "?=", $end_en_pos+1); 
     2440 
     2441        // Extract the encoded string 
     2442        $encstr = substr($input, $pos+2, ($end_pos-$pos-2)); 
     2443        // Extract the remaining string 
     2444        $input = substr($input, $end_pos+2); 
     2445 
     2446        // Decode the string fragement 
     2447        $out .= rcube_imap::_decode_mime_string_part($encstr); 
     2448      } 
     2449 
     2450      // Deocde the rest (if any) 
     2451      if (strlen($input) != 0) 
     2452         $out .= rcube_imap::decode_mime_string($input, $fallback); 
     2453 
     2454       // return the results 
    24422455      return $out; 
    2443       } 
     2456    } 
    24442457 
    24452458    // no encoding information, use fallback 
Note: See TracChangeset for help on using the changeset viewer.