yang991178 / fluent-reader

Modern desktop RSS reader built with Electron, React, and Fluent UI
https://hyliu.me/fluent-reader/
BSD 3-Clause "New" or "Revised" License
7.79k stars 425 forks source link

Use xml:base for relative URLs #692

Open delan opened 1 month ago

delan commented 1 month ago

Atom spec says:

Any element defined by this specification MAY have an xml:base attribute [W3C.REC-xmlbase-20010627]. When xml:base is used in an Atom Document, it serves the function described in section 5.1.1 of [RFC3986], establishing the base URI (or IRI) for resolving any relative references found within the effective scope of the xml:base attribute.

Right now, if you have a feed like this published at https://example.com/feed.xml, the images will load in Thunderbird and FreshRSS (https://example.com/posts/images/bird.jpg), but not fluent-reader (https://example.com/images/bird.jpg). Those other clients even handle relative URLs without xml:base, but I don’t think that’s guaranteed by the spec.

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<updated>2024-09-24T14:35:15.950Z</updated>
<title>feed</title>
<entry>
<id>https://example.com/posts/123.html</id>
<link rel="alternate" href="https://example.com/posts/123.html"/>
<published>2024-09-21T14:36:37.520Z</published>
<title>entry</title>
<content type="html" xml:base="https://example.com/posts/">
&lt;img src=&quot;images/bird.jpg&quot;&gt;
</content>
</entry>
</feed>

One workaround that fluent-reader accepts is to add a <base> tag inside the <content>:

<content type="html" xml:base="https://example.com/posts/">
&lt;base href="https://example.com/posts/"&gt;
&lt;img src=&quot;images/bird.jpg&quot;&gt;
</content>