radgeek / feedwordpress

FeedWordPress: simple and flexible Atom/RSS syndication for WordPress
118 stars 63 forks source link

Multibyte characters caused errors in some feeds. #91

Open gatokichi opened 7 years ago

gatokichi commented 7 years ago

SyndicatedPost::content() in syndicatedpost.class.php

    if ( empty($excerpt) or $theExcerpt == $theContent ) :
        # If content is available, generate an excerpt.
        if ( strlen(trim($content)) > 0 ) :
            $excerpt = strip_tags($content);
            if (strlen($excerpt) > 255) :
                $excerpt = substr($excerpt,0,252).'...';
            endif;
        endif;
    endif;

substr() is not good with some multibyte feeds.

radgeek commented 7 years ago

Good point, thanks. I incorporated a change to use mb_substr (using the encoding supplied by SimplePie) to do the excerpting. It should be incorporated into the most recent version, 2017.1004. If you have a good test-case feed that I could double-check my solution against, let me know. Thanks!