minutils / feed-on-feeds

Released in 2003, saw the rise and fall of Google Reader, reached perfection in 2011
http://feedonfeeds.com/
GNU General Public License v2.0
14 stars 9 forks source link

Relative image links not being rewritten #57

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Some comics' RSS feeds (such as Dumm Comics) use relative paths to their
images' SRC and links' HREF attributes. While this is technically an error
in the RSS feed (since feeds are supposed to be portable), other readers
(notably Google Reader) rewrite the relative paths, which helps prevent the
problem.

For whatever it's worth, for my own RSS feeds I have written a function
"rewriteRelative" which fixes relative paths; perhaps it would be useful to
integrate it into FonF:

// Rewrite all relative links in a chunk of HTML/XML/etc. to point to the
appropriate place
function rewriteRelative($html, $base) {
        // generate server-only replacement for root-relative URLs
        $server = preg_replace('@^([^\:]*)://([^/*]*)(/|$).*@', '\1://\2/',
$base);

        // replace root-relative URLs
        $html = preg_replace('@\<([^>]*) (href|src)="/([^"]*)"@i',
                '<\1 \2="' . $server . '\3"', $html);

        // replace base-relative URLs (kludgy, but I couldn't get ! to work)
        $html = preg_replace('@\<([^>]*)
(href|src)="(([^\:"])*|([^"]*:[^/"].*))"@i',
                '<\1 \2="' . $base . '\3"', $html);

        return $html;
}

It's a little kludgy but it does the job.

Original issue reported on code.google.com by fluffy%b...@gtempaccount.com on 6 May 2009 at 3:53

GoogleCodeExporter commented 9 years ago
After looking into it a bit more, it appears that SimplePie IS already rewriting
content links, but for some reason the images aren't displaying, even though 
they're
getting rewritten to something that's technically valid.

I wonder if this is more a case of the site in question (dummcomics.com) being 
a bit
overzealous with hotlink prevention, since if I manually load one of the image 
URLs,
it shows up, and then promptly disappears from FonF - and stays disappeared 
when I go
to the site itself (until I reload).

Original comment by fluffy%b...@gtempaccount.com on 7 May 2009 at 6:16

GoogleCodeExporter commented 9 years ago
Yeah, that's definitely the case. Feel free to close this ticket. Sorry for the
inconvenience.

Original comment by fluffy%b...@gtempaccount.com on 7 May 2009 at 6:29