Support » Plugin: WP-RecentComments » [Plugin: WP-RecentComments] function rc_get_avatar_url fails on some html

  • Hi there!

    When the $code variable has this value, then the function rc_get_avatar_url($code) won´t work. The alt, width and height attributes will still remain in the return value.

    <img src="http://dev.sjukhuslakaren.se/wp-content/uploads/userphoto/8.thumbnail.jpg" alt="Mikael Rolfs" width="80" height="60" class="photo" />

    To solve the problem, I added this code:

    function rc_get_avatar_url($code) {
    
    	//MY FIX - START
    	$quotes = array('"', "'");
    
    	foreach ($quotes as $q) {
    
    		$pos_start = strpos($code, $q.'http');
    		$pos_end = strpos($code, $q, $pos_start + 1);
    
    		if ($pos_start !== false && $pos_end !== false) {
    
    			$src = substr($code, $pos_start + 1, $pos_end - $pos_start - 1);
    			$src = preg_replace(array('/&/i'), array('&'), $src);
    			return $src;
    		}
    	}
    	//MY FIX - END
    
    	return preg_replace(array('/^.+(src=)(\"|\')/i', '/(\"|\')\sclass=(\"|\').+$/i', '/&/i'), array('', '', '&'), $code);
    }

    Could this be added to the official version? Or maybe be done in a bettar way?

    Best Regards
    Patrik Hultgren

    http://wordpress.org/extend/plugins/wp-recentcomments/

Viewing 1 replies (of 1 total)
  • fix this bug plz

    function rc_get_avatar_url($code)
    {
            $code = preg_replace('/(&#(x0*26|0*38);)/i', '&', $code);
    
            if ( preg_match('/src=([\'"]*)([^\'"]+)\1/', $code, $matches) )
            {
                    return $matches[2];
            }
    
            return "";
    }
Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: WP-RecentComments] function rc_get_avatar_url fails on some html’ is closed to new replies.