Issue 57 in feed-on-feeds: Relative image links not being rewritten

4 views
Skip to first unread message

codesite...@google.com

unread,
May 6, 2009, 11:54:29 AM5/6/09
to feed-on-fe...@googlegroups.com
Status: New
Owner: ----

New issue 57 by flu...@beesbuzz.biz: Relative image links not being
rewritten
http://code.google.com/p/feed-on-feeds/issues/detail?id=57

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.

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

codesite...@google.com

unread,
May 7, 2009, 2:30:39 PM5/7/09
to feed-on-fe...@googlegroups.com

Comment #2 on issue 57 by flu...@beesbuzz.biz: Relative image links not
being rewritten
http://code.google.com/p/feed-on-feeds/issues/detail?id=57

Yeah, that's definitely the case. Feel free to close this ticket. Sorry for
the
inconvenience.

Reply all
Reply to author
Forward
0 new messages