kiwix / kiwix-xulrunner

[ARCHIVED] Legacy Kiwix desktop solution for Windows/macOS/Linux
https://download.kiwix.org/release/kiwix-xulrunner/
GNU General Public License v3.0
111 stars 28 forks source link

Wrong redirection handling #508

Closed kelson42 closed 6 years ago

kelson42 commented 6 years ago

From @kelson42 on July 19, 2017 20:10

Currently the kiwix-lib, if a redirect is found, search the target and return the target page body. It works so far the targeted page is at the same path level like the redirect. If not all relative URLs will probably fail to load properly.

As a workaround, in kiwix-serve a node as been introduced, but this is not the proper answer to that problem and this fixes only kiwix-serve.

To fix that problem, probably the kiwix-lib should returns a proper code or HTML redirection code.

Copied from original issue: kiwix/kiwix-lib#70

kelson42 commented 6 years ago

From @mgautierfr on September 4, 2017 10:7

As a workaround, in kiwix-serve a node as been introduced, but this is not the proper answer to that problem and this fixes only kiwix-serve.

Hooo, that why the base node is for ? I was wondering why we add this node while rewriting the url in the document in the same time.

To fix that problem, probably the kiwix-lib should returns a proper code or HTML redirection code.

I agree with this. Redirections are better handled on the client side. But it is a bit tricky to do. It is a big API change as all clients assume that they will not get any redirection and directly get the content to display.

Until this issue is fixed, kiwix-lib has a method that return the content of the asked url but also the baseUrl (who is the url of real article used). This could be used to detect a redirection and fix url in the webview. Sadly, this is not exposed in the JNI API. I can quickly add it (as I made it for the title argument https://github.com/kiwix/kiwix-lib/commit/d3acae1fd2bc56cfc38e005791eac2d9eba64b71)

kelson42 commented 6 years ago

Yes, we should probably add a new parameter to the existing kiwix-lib method(s) to specificaly avoid to resolve redirects.

kelson42 commented 6 years ago

From @okkebal on November 7, 2017 8:38

The new run of StackExchange is being published to the Android version. The files show up in the "online" tab in "get content". So android users will start downloading and trying these files. Due to this issue the pages do not load correctly. This will be a bad experience for our users. The files should only be published in the Android version if they work in the Android version.

kelson42 commented 6 years ago

From @automactic on February 26, 2018 16:5

I think we just need to add something similar to std::vector<std::string> getRedirectedURL(const std::string& url) const;, but I know this might be easier said than done.

The API should:

kelson42 commented 6 years ago

@automactic What would trigger this call? Would you call it each time you try to open an url?

kelson42 commented 6 years ago

From @automactic on February 27, 2018 14:40

@kelson42 I think so, yes, a call will be made every time opening a URL, since there is no way to tell if a url should redirect and every url could potentially redirect.


Another way to solve this is to get rid of redirections. Think of urls as primary keys of resources (html, css, js, etc) in a zim file. We resolve all the redirections during offline time.

kelson42 commented 6 years ago

Done

kelson42 commented 6 years ago

From @okkebal on April 30, 2018 9:52

PS: the latest nightly for Android (2018-04-29) does not have this fix: Stack Exchange Zim files still render the same....

I guess you need to update a library?

kelson42 commented 6 years ago

@okkebal Kiwix-Android needs to be updated (in version 3.0). Kiwix serve will be fixed this week IMO, Kiwix for iOS to be release in the next day is also fixed.

kelson42 commented 6 years ago

This issue was moved to kiwix/kiwix-lib#137