Ticket #7220: press-this-7-2-410am.diff

File press-this-7-2-410am.diff, 1.1 KB (added by noel, 4 years ago)

Fix for image src XSS injection

  • wp-admin/press-this.php

     
    115115} 
    116116 
    117117// Ajax Requests 
    118 $title = wp_specialchars(stripslashes($_GET['t'])); 
     118$title = wp_specialchars(aposfix(stripslashes($_GET['t']))); 
    119119 
    120120$selection = str_replace("\n", "<br />", aposfix( stripslashes($_GET['s']) ) ); 
    121121$url = clean_url($_GET['u']); 
     
    178178 
    179179if($_REQUEST['ajax'] == 'photo_images') { 
    180180        function get_images_from_uri($uri) { 
    181                 if(preg_match('/\.(jpg|png|gif)/', $uri) && !strpos($uri,'blogger.com'))  
     181                if(preg_match('/\.(jpg|jpe|jpeg|png|gif)/', $uri) && !strpos($uri,'blogger.com'))  
    182182                        return "'".$uri."'"; 
    183183 
    184184                $content = wp_remote_fopen($uri); 
     
    186186                 
    187187                $host = parse_url($uri); 
    188188                 
    189                 $pattern = '/<img ([^>]*)src=(\"|\')(.+?)(\2)([^>\/]*)\/*>/is'; 
     189                $pattern = '/<img ([^>]*)src=(\"|\')([^<>]+?\.(png|jpeg|jpg|jpe|gif))(\2)([^>\/]*)\/*>/is'; 
    190190                preg_match_all($pattern, $content, $matches); 
    191191                 
    192192                if ( empty($matches[1]) ) return '';