Corewala / Buran

Gemini browser for Android
GNU General Public License v3.0
95 stars 10 forks source link

Not removing dot segments when resolving relative URLs #47

Open acidus99 opened 10 months ago

acidus99 commented 10 months ago

Buran 1.12 is not properly resolving relative URLs. Specifically, Buran is not removing "dot segments" (e.g. ../ or ./) which is required by RFC 3986 when resolving URLs.

Look at this URL: gemini://rawtext.club/~winter/gemlog/2023/8-18.gmi

At the bottom of the page there is a link line:

=> .. gemlog

This relative URL should be resolved to the fully qualified URL gemini://rawtext.club/~winter/gemlog/, which should then be sent in the Gemini request. Instead, it Buran sends the URL gemini://rawtext.club/~winter/gemlog/2023/.. in the request. While some servers may handle that URL, most don't, including that capsule, which returns a 50 server error saying it's a bad request.

When resolving relative URLs, you should use the algorithm described in section 5.2 of RFC 3986, specifically section 5.2.4: Remove Dot Segments. Most URL libraries do this automatically when parsing/resolving URLs. Perhaps Buran is using an out-of-date library, or not using a proper URL parsing library.

ProjectMoon commented 4 months ago

My server (Agate) seems to handle this, but it causes weird link loops. As I have documents nested a few levels deep, Buran cannot properly go all the way back up the tree when I am clicking through a bunch of .. links.