readium / kotlin-toolkit

A toolkit for ebooks, audiobooks and comics written in Kotlin
https://readium.org/kotlin-toolkit
BSD 3-Clause "New" or "Revised" License
185 stars 81 forks source link

[Bug] Cannot access a navigation feed that contains a URL encoded ":" #548

Open mcpierce opened 3 months ago

mcpierce commented 3 months ago

Describe the bug

My application is using the OPDS1Parser from v2.4.1 to read from a server. When it downloads an acquisition link like this following:

Lady+Baltimore%3A+The+Witch+Queens/volumes/2021?unread=false

it is throwing the exception:

org.readium.r2.shared.util.http.HttpException: HTTP error: MalformedRequest

The root cause (next layer down in the exception chain) is:

java.net.MalformedURLException: no protocol: Dark+Horse+Comics/series/Lady+Baltimore:+The+Witch+Queens?unread=false

I've included the OPDS page feed in the additional context below.

How to reproduce?

  1. Download an OPDS payload containing a link with a URL encoded ":" in the path.
  2. Attempted to open that link using OPDS1Parser.parseUrlString(url, httpClient)).
  3. Exception is thrown when the expected result is to load the URL.

Readium version

2.4.1

Android API version

14

Additional context

The URL (as referenced from a desktop computer) is:

http://localhost:7171/opds/collections/publishers/Dark+Horse+Comics/series/Lady+Baltimore%3A+The+Witch+Queens?unread=false

and the payload returned is:

<feed xmlns="http://www.w3.org/2005/Atom">
<title>Series: Lady Baltimore: The Witch Queens</title>
<id xmlns="">Lady+Baltimore%3A+The+Witch+Queens?unread=false</id>
<icon xmlns="">/favicon.png</icon>
<author xmlns="">
<name>ComiXed</name>
<uri>http://www.comixedproject.org/</uri>
</author>
<updated xmlns="">2024-07-20T16:53:42Z</updated>
<link xmlns="" type="application/atom+xml; profile=opds-catalog; kind=navigation" rel="start" href="root.xml"/>
<link xmlns="" type="application/opensearchdescription+xml" rel="search" href="search.xml" title="Search the library"/>
<link xmlns="" type="application/atom+xml; profile=opds-catalog; kind=navigation" rel="self" href="Lady+Baltimore%3A+The+Witch+Queens?unread=false"/>
<entry>
<title>v2021</title>
<id xmlns="">1450591362</id>
<updated xmlns="">2024-07-20T16:53:42Z</updated>
<content xmlns=""/>
<link type="application/atom+xml; profile=opds-catalog; kind=acquisition" rel="subsection" href="Lady+Baltimore%3A+The+Witch+Queens/volumes/2021?unread=false"/>
</entry>
</feed>
qnga commented 3 months ago

What is your OPDS 1 server? I can't find any reference documentation about use of relative Urls in OPDS1 or ATOM. @HadrienGardeur Do you have any insight on this?

mcpierce commented 3 months ago

@qnga I was refactoring the feed to provide URLs relative to the self link based on an example catalog online and how readium behaves when consuming it.

Should my server instead returnl acquistion links that are absolute URIs rather than ones relative to the self link?

qnga commented 3 months ago

Ok, I missed the existence of the self link in OPDS 1 too. Unlike OPDS 2, it seems to allow relative self links. Relative to what? I don't know. If it's relative to the location we got the feed from, I can't see the point of a self link since we need an URL to that location anyway.

mcpierce commented 3 months ago

@qnga So what is your recommendation for this? Is it a bug to be fixed?