dimtion / Shaarlier

Simple Android app for sharing links on Shaarli.
GNU General Public License v3.0
97 stars 11 forks source link

Absolute links generated #51

Closed eazrael closed 3 years ago

eazrael commented 3 years ago

I am running Shaarli 0.12.0 and Shaarlier 1.8.0. I am notsure when issue started and whether it is a butin Shaarli or in Shaarlier.

I am running Shaarli in a subdirectory and not in the hosts root dir. Currently sharing a links fails with an error message that link could not be shared. The link was successfully submitted to Shaarli, but another request is failing afterwards causing Shaarlier to report the error. In the Apache logs there are these two entries: x.x.x.x - - [26/Oct/2020:00:52:26 +0100] "POST /shaarli/api/v1/links HTTP/1.1" 201 279 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36" x,x.x.x - - [26/Oct/2020:00:52:26 +0100] "GET /api/v1/links/1897 HTTP/1.1" 404 196 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36"

The link posting was successful, but the second request failed as the path is not relative to the shaarli directory. I am not sure who is generating the link. I haven't debugged it, bi in the source file RestAPINetworkManager.java the Link URL is generated on two different ways:

   public void pushLink(Link link) throws IOException {
        String url = new URL(link.getAccount().getUrlShaarli() + LINK_URL).toExternalForm();
...
    public Link prefetchLinkData(Link link) throws IOException {
        String url = new URL(this.mAccount.getUrlShaarli() + LINK_URL).toExternalForm();

link.getAccount() is only used in this method, all others use this.mAccount. Maybe this is the error?

dimtion commented 3 years ago

Thank you @eazrael , this detailed report helped me a lot pin point the issue!

The issue is due to an invalid redirection header, returned by Shaari. I've posted a PR here that should fix the issue: https://github.com/shaarli/Shaarli/pull/1616

eazrael commented 3 years ago

I am glad you understood my post despite all the mistakes :-)

And many thanks for solving this issue :-)