Changeset ea206d3 in github


Ignore:
Timestamp:
Sep 1, 2006 6:01:31 AM (7 years ago)
Author:
thomascube <thomas@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
3ea0e32
Parents:
10c92be
Message:

Improved message parsing and HTML validation

Location:
program
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • program/include/rcube_imap.inc

    r107bde9 rea206d3  
    10111011        if (!empty($part[6]) && $part[6]!='NIL') 
    10121012          $struct->size = intval($part[6]); 
    1013  
     1013           
    10141014        // read part disposition 
    1015     $di = count($part) - 3; 
     1015    $di = count($part) - 2; 
    10161016    if (is_array($part[$di])) 
    10171017      { 
  • program/steps/mail/func.inc

    r10c92be rea206d3  
    677677    if (!$safe)  // remove remote images and scripts 
    678678      { 
    679       $remote_patterns = array('/(src|background)=(["\']?)([hftps]{3,5}:\/{2}[^"\'\s]+)(\2|\s|>)/Ui', 
    680                            //  '/(src|background)=(["\']?)([\.\/]+[^"\'\s]+)(\2|\s|>)/Ui', 
     679      $remote_patterns = array('/<img\s+(.*)src=(["\']?)([hftps]{3,5}:\/{2}[^"\'\s]+)(\2|\s|>)/Ui', 
     680                               '/(src|background)=(["\']?)([hftps]{3,5}:\/{2}[^"\'\s]+)(\2|\s|>)/Ui', 
    681681                               '/(<base.*href=["\']?)([hftps]{3,5}:\/{2}[^"\'\s]+)([^<]*>)/i', 
    682682                               '/(<link.*href=["\']?)([hftps]{3,5}:\/{2}[^"\'\s]+)([^<]*>)/i', 
     
    685685                               '/<script.+<\/script>/Umis'); 
    686686 
    687       $remote_replaces = array('',  // '\\1=\\2#\\4', 
    688                             // '\\1=\\2#\\4', 
     687      $remote_replaces = array('<img \\1src=\\2./program/blank.gif\\4', 
    689688                               '', 
    690                                '',  // '\\1#\\3', 
     689                               '', 
     690                               '', 
    691691                               'none', 
    692692                               'none', 
     
    767767    $body = preg_replace("/##string_replacement\{([0-9]+)\}##/e", "\$replace_strings[\\1]", join("\n", $a_lines)); 
    768768     
    769     return "<div class=\"pre\">\n".$body."\n</div>"; 
     769    return "<div class=\"pre\">".$body."\n</div>"; 
    770770    } 
    771771  } 
     
    948948         
    949949      foreach ($sa_inline_objects as $inline_object) 
    950         $a_replaces['cid:'.$inline_object->content_id] = sprintf($get_url, $inline_object->mime_id); 
     950        $a_replaces['cid:'.$inline_object->content_id] = htmlspecialchars(sprintf($get_url, $inline_object->mime_id)); 
    951951       
    952952      // add replace array to each content part 
     
    10931093      { 
    10941094      if (strpos($attach_prop->mimetype, 'image/')===0) 
    1095         $out .= sprintf("\n<hr />\n<p align=\"center\"><img src=\"%s&_part=%s\" alt=\"%s\" title=\"%s\" /></p>\n", 
    1096                         $GET_URL, $attach_prop->mime_id, 
     1095        $out .= sprintf("\n<hr />\n<p align=\"center\"><img src=\"%s&amp;_part=%s\" alt=\"%s\" title=\"%s\" /></p>\n", 
     1096                        htmlspecialchars($GET_URL), $attach_prop->mime_id, 
    10971097                        $attach_prop->filename, 
    10981098                        $attach_prop->filename); 
     
    11221122  while (($pos = strpos($body_lc, '<style', $last_style_pos)) && ($pos2 = strpos($body_lc, '</style>', $pos))) 
    11231123    { 
    1124     $pos2 += 8; 
    1125     $body_pre = substr($body, 0, $pos); 
    1126     $styles = substr($body, $pos, $pos2-$pos); 
    1127     $body_post = substr($body, $pos2, strlen($body)-$pos2); 
    1128      
     1124    $pos = strpos($body_lc, '>', $pos)+1; 
     1125 
    11291126    // replace all css definitions with #container [def] 
    1130     $styles = rcmail_mod_css_styles($styles, $container_id); 
    1131      
    1132     $body = $body_pre . $styles . $body_post; 
     1127    $styles = rcmail_mod_css_styles(substr($body, $pos, $pos2-$pos), $container_id); 
     1128 
     1129    $body = substr($body, 0, $pos) . $styles . substr($body, $pos2);     
    11331130    $last_style_pos = $pos2; 
    11341131    } 
  • program/steps/mail/get.inc

    rf7bfec9 rea206d3  
    8888    if ($ctype_primary=='text' && $ctype_secondary=='html') 
    8989      { 
     90      // we have to analyze the whole structure again to find inline objects 
     91      list($MESSAGE['parts']) = rcmail_parse_message($MESSAGE['structure'], 
     92                                                     array('safe' => (bool)$_GET['_safe'], 
     93                                                           'prefer_html' => TRUE, 
     94                                                           'get_url' => $GET_URL.'&_part=%s')); 
     95      $part = &$MESSAGE['parts'][0]; 
     96 
    9097      // get part body if not available 
    9198      if (!$part->body) 
    9299        $part->body = $IMAP->get_message_part($MESSAGE['UID'], $part->mime_id, $part);       
    93100 
    94       list($MESSAGE['parts']) = rcmail_parse_message($part, 
    95                                                      array('safe' => (bool)$_GET['_safe'], 
    96                                                            'prefer_html' => TRUE, 
    97                                                            'get_url' => $GET_URL.'&_part=%s')); 
    98  
    99101      $OUTPUT = new rcube_html_page(); 
    100       $OUTPUT->write(rcmail_print_body($MESSAGE['parts'][0], (bool)$_GET['_safe'])); 
     102      $OUTPUT->write(rcmail_print_body($part, (bool)$_GET['_safe'])); 
    101103      } 
    102104    else 
  • program/steps/mail/show.inc

    r8d4bcda rea206d3  
    109109      else 
    110110        $out .= sprintf('<li><a href="%s&amp;_part=%s" onclick="return %s.command(\'load-attachment\',{part:\'%s\', mimetype:\'%s\'},this)">%s</a></li>'."\n", 
    111                         htmlentities($GET_URL), 
     111                        htmlspecialchars($GET_URL), 
    112112                        $attach_prop->mime_id, 
    113113                        $JS_OBJECT_NAME, 
  • program/steps/settings/save_identity.inc

    r89406f3 rea206d3  
    6262    } 
    6363        
    64   if ($updated && !empty($_POST['_standard'])) 
     64  if ($updated) 
    6565    { 
    6666    show_message('successfullysaved', 'confirmation'); 
    6767 
    6868    // mark all other identities as 'not-default' 
    69     $DB->query("UPDATE ".get_table_name('identities')." 
    70                 SET ".$DB->quoteIdentifier('standard')."='0' 
    71                 WHERE  user_id=? 
    72                 AND    identity_id<>? 
    73                 AND    del<>1", 
    74                 $_SESSION['user_id'], 
    75                 get_input_value('_iid', RCUBE_INPUT_POST)); 
     69    if (!empty($_POST['_standard'])) 
     70      $DB->query("UPDATE ".get_table_name('identities')." 
     71                  SET ".$DB->quoteIdentifier('standard')."='0' 
     72                  WHERE  user_id=? 
     73                  AND    identity_id<>? 
     74                  AND    del<>1", 
     75                  $_SESSION['user_id'], 
     76                  get_input_value('_iid', RCUBE_INPUT_POST)); 
    7677     
    7778    if ($_POST['_framed']) 
Note: See TracChangeset for help on using the changeset viewer.