Closed freispiel closed 4 years ago
I think you mean relative URLs don't work?
This happens because the feed preview is aware of where the feed comes from. However the livemarks are just dumb bookmarks and have no context. I am not sure how to best fix this. Perhaps by checking during parsing of the feed, and generating absolute URLs relative to the feed location before creating the bookmark?
I see, @ali1234, thank you. My thoughts were: Before creating the bookmark,
/rss/channel/item[*]/link
is a proper URL (regexp or so).
/rss/channel/item[*]/link
starts with a "/" and /rss/channel/link
is a proper URL.item[*]/link
= channel/link
+ item[*]/link
" before calling the create-bookmark
function.Does that makes sense?
Yes, I agree, the best place is probably during parsing of the feed. I had a quick look at feed-parser.js, but I'm afraid I cannot create a patch (don't understand it well enough).
You don't need to handle it manually, you just do Url(link, base)
. Livemarks already tries to do this:
https://github.com/nt1m/livemarks/blob/master/shared/livemark-store.js#L75
It isn't working with your example because the feedUrl is itself relative.
Apologies, I'm not sure I understand:
It isn't working with your example because the feedUrl is itself relative.
In my example, there is
<channel>
<title>Test title</title>
<atom:link href="/category/test/feed/" rel="self" type="application/rss+xml" />
<link>https://pastebin.com</link>
This link is absolute. Then there is
<item>
<title>Item 1 title</title>
<link>/category/test/item-1/</link>
which is relative.
How is a relative URL then ending up in feedUrl
?
It is obviously not taken from /rss/channel/link
, because if it were, then it would not break URL(feed.siteUrl, feed.feedUrl).href
...
I see that relative links are not clickable in the preview :thinking: or more accurately point to moz-extension://38d2cb5a-1cbc-4294-bb68-1afd33fa1039/relative/path
which I guess is not very useful.
steps to reproduce in firefox:
https://github.com/torvalds.atom
moz-extension://38d2cb5a-1cbc-4294-bb68-1afd33fa1039/pages/subscribe/subscribe.html?https%3A%2F%2Fgithub.com%2Ftorvalds.atom
moz-extension://38d2cb5a-1cbc-4294-bb68-1afd33fa1039/torvalds/linux
<a ... href="/torvalds/linux" ...>torvalds/linux</a>
Add-on version: 2.2
Describe the bug There are Wordpress blogs that contain RSS feeds with only absolute-path links in them. I.e. protocol and hostname of an item are missing. This causes
[Exception... "Component returned failure code: 0x804b000a (NS_ERROR_MALFORMED_URI) [nsIIOService.newURI]" nsresult: "0x804b000a (NS_ERROR_MALFORMED_URI)" location: "JS frame :: chrome://browser/content/parent/ext-history.js :: getVisits :: line 222" data: no]
and then
Error: Invalid bookmark: {"title":"Item 1 title","type":1,"url":"/category/test/item-1/","parentGuid":"v-i_T30roDvj"}
Interestingly enough, the feed preview in Firefox is able to handle these invalid URLs properly -- but only the preview. The feed is never processed.
To Reproduce
Expected behavior The
<channel>
tag is containing a proper URL in<link>
, and<link>
of an<item>
starts with a "/". Therefore, it should not be too difficult to compile a full URL before trying to store it as a bookmark.Extra context The sample that I put on https://pastebin.com/raw/v99u0LiJ is directly taken from a Wordpress feed (minus some private content). Yes, of course I would like Wordpress not to generate invalid RSS feeds in the first place, but I cannot do anything about that: These are not my blogs, I am only reading them....