mbirth / ttrss_plugin-af_feedmod

Article Filter plugin for Tiny-Tiny-RSS to replace article stubs by website contents.
90 stars 22 forks source link

Modify article content #20

Open oscar-b opened 11 years ago

oscar-b commented 11 years ago

First of all, thanks for an excellent plugin! It is the reason I'm now using tt-rss :)

I do have a suggestion though; a way to modify the article content after it's been fetched. This would allow for all kind of nice things, but the problem I have a the moment is a site that uses scheme-less img hrefs, which aren't handled properly by the feed reader I'm using.

I took a stab at implementing a fix for this particular issue, something like this seems to work very well (to be placed right after the cleanup code):

$nodelist = $basenode->getElementsByTagName("img");
foreach($nodelist as $node) {
    $imgsrc = $node->getAttribute("src");
    if (substr($imgsrc, 0, 2) == '//') {
        $node->setAttribute("src", "http:" . $imgsrc);
    }
}
oscar-b commented 11 years ago

Ah yes sorry, there's some code missing for actually saving the article, but you get the idea.

mbirth commented 11 years ago

Hmm ... the nicest way would be more feed parameters with PHP code which would be executed. But this would also open a giant security hole for shared installations. But I'll think about some way.