Kovah / LinkAce

LinkAce is a self-hosted archive to collect links of your favorite websites.
https://www.linkace.org
GNU General Public License v3.0
2.64k stars 164 forks source link

IPv6 encoding incorrect #704

Open chrissawyerfan4 opened 1 year ago

chrissawyerfan4 commented 1 year ago

I tested #703 on a fresh server and chose not to buy an IPv4 address because, well, we're out and reusing someone else's costs extra nowadays.

Address encoding issue 1

  1. Navigate to http://[2a01:4f8:c17:cfd5::1]/
  2. Firefox reports a protocol error. Wireshark shows this HTTP response:
    
    HTTP/1.0 302 Found
    Date: Sun, 15 Oct 2023 14:03:07 GMT
    Server: Apache/2.4.57 (Debian)
    Cache-Control: no-cache, private
    Location: http://%5B2a01:4f8:c17:cfd5::1%5D/setup/start
    Connection: close
    Content-Type: text/html; charset=UTF-8

<!DOCTYPE html>

Redirecting to http://%5B2a01:4f8:c17:cfd5::1%5D/setup/start Redirecting to http://%5B2a01:4f8:c17:cfd5::1%5D/setup/start.

(Note: if you see red highlighted lines, that's github's broken http syntax parsing or something, not me trying to indicate where the error is. It seems to think that HTTP has only headers, no status line or body!)

## Address encoding issue 2

0. Navigate to http://[2a01:4f8:c17:cfd5::1]/setup/start
   - Note: the JavaScript console reports that `document.querySelector('meta[property="la-app-data"]')` returns `null` from `resources/assets/js/components/Base.js`, not sure what that's used for
2. Click the continue button ("Check Requirements") which is an `<a href='http://%5B2a01:4f8:c17:cfd5::1%5D/setup/requirements'>`
3. Firefox ignores the click altogether

All other links are also broken, for example the main menu on the guest page.

## Installation issue

The [documentation instructs](https://www.linkace.org/docs/v1/setup/setup-without-docker/) one to "Download the LinkAce .zip package from the [release page](https://github.com/Kovah/LinkAce/releases/latest)."

$ wget https://github.com/Kovah/LinkAce/releases/download/v1.12.2/linkace-v1.12.2.zip --2023-10-15 14:01:32-- https://github.com/Kovah/LinkAce/releases/download/v1.12.2/linkace-v1.12.2.zip Resolving github.com (github.com)... 140.82.121.4 Connecting to github.com (github.com)|140.82.121.4|:443... failed: Network is unreachable.


Linkace.org and demo.linkace.org work perfectly fine via the v6-only connection (tested by using `ssh -D 0:8080` with that IPv6-only server and configuring that as socks5+dns proxy in Firefox), so those could be used as distribution method.

As an aside, the zip structure is a bit convoluted: `linkace-v1.12.2.zip` contains another zip file called `linkace.zip` which contains a [tarbomb](https://en.wikipedia.org/wiki/Tar_(computing)#Tarbomb) (all files in `.` rather than in a subdirectory). I don't know about others, but for me it would be more expected to have the files contained in a subdirectory of the zip that one downloads.

## Link adding issue

0. Add an entry in `/etc/hosts`  and navigate to the link adding page at e.g. http://linkacetest6.local/links/create
1. Enter `http://[2a01:4f8:c17:cfd5::1]/` as the link and try to add it
2. Error page is shown and link is not added. Log:

[2023-10-15 15:31:28] production.ERROR: Unable to parse URI: http://%5B2a01:4f8:c17:cfd5::1%5D {"userId":1,"exception":"[object] (GuzzleHttp\Psr7\Exception\MalformedUriException(code: 0): Unable to parse URI: http://%5B2a01:4f8:c17:cfd5::1%5D at /var/www/LinkAce/vendor/guzzlehttp/psr7/src/Uri.php:85) [stacktrace]

0 /var/www/LinkAce/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php(218): GuzzleHttp\Psr7\Uri->__construct()

1 /var/www/LinkAce/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php(179): GuzzleHttp\RedirectMiddleware::redirectUri()

2 /var/www/LinkAce/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php(89): GuzzleHttp\RedirectMiddleware->modifyRequest()

3 /var/www/LinkAce/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php(73): GuzzleHttp\RedirectMiddleware->checkRedirect()

4 /var/www/LinkAce/vendor/guzzlehttp/promises/src/Promise.php(204): GuzzleHttp\RedirectMiddleware->GuzzleHttp\{closure}()

5 /var/www/LinkAce/vendor/guzzlehttp/promises/src/Promise.php(153): GuzzleHttp\Promise\Promise::callHandler()

6 /var/www/LinkAce/vendor/guzzlehttp/promises/src/TaskQueue.php(48): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()

7 /var/www/LinkAce/vendor/guzzlehttp/promises/src/Promise.php(248): GuzzleHttp\Promise\TaskQueue->run()

8 /var/www/LinkAce/vendor/guzzlehttp/promises/src/Promise.php(224): GuzzleHttp\Promise\Promise->invokeWaitFn()

9 /var/www/LinkAce/vendor/guzzlehttp/promises/src/Promise.php(269): GuzzleHttp\Promise\Promise->waitIfPending()

10 /var/www/LinkAce/vendor/guzzlehttp/promises/src/Promise.php(226): GuzzleHttp\Promise\Promise->invokeWaitList()

11 /var/www/LinkAce/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()

12 /var/www/LinkAce/vendor/guzzlehttp/guzzle/src/Client.php(189): GuzzleHttp\Promise\Promise->wait()

13 /var/www/LinkAce/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(961): GuzzleHttp\Client->request()

14 /var/www/LinkAce/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(823): Illuminate\Http\Client\PendingRequest->sendRequest()

15 /var/www/LinkAce/vendor/laravel/framework/src/Illuminate/Support/helpers.php(247): Illuminate\Http\Client\PendingRequest->Illuminate\Http\Client\{closure}()

16 /var/www/LinkAce/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(821): retry()

17 /var/www/LinkAce/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(699): Illuminate\Http\Client\PendingRequest->send()

18 /var/www/LinkAce/app/Http/Controllers/FetchController.php(138): Illuminate\Http\Client\PendingRequest->get()

19 /var/www/LinkAce/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): App\Http\Controllers\FetchController->htmlForUrl()

20 /var/www/LinkAce/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(43): Illuminate\Routing\Controller->callAction()

[...]

71 {main}

"} [2023-10-15 15:31:29] production.ERROR: Unable to parse URI: http://%5B2a01:4f8:c17:cfd5::1%5D/guest/links {"userId":1,"exception":"[object] (GuzzleHttp\Psr7\Exception\MalformedUriException(code: 0): Unable to parse URI: http://%5B2a01:4f8:c17:cfd5::1%5D/guest/links at /var/www/LinkAce/vendor/guzzlehttp/psr7/src/Uri.php:85) [stacktrace]

0 /var/www/LinkAce/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php(218): GuzzleHttp\Psr7\Uri->__construct()

1 /var/www/LinkAce/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php(179): GuzzleHttp\RedirectMiddleware::redirectUri()

2 /var/www/LinkAce/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php(89): GuzzleHttp\RedirectMiddleware->modifyRequest()

3 /var/www/LinkAce/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php(73): GuzzleHttp\RedirectMiddleware->checkRedirect()

4 /var/www/LinkAce/vendor/guzzlehttp/promises/src/Promise.php(204): GuzzleHttp\RedirectMiddleware->GuzzleHttp\{closure}()

5 /var/www/LinkAce/vendor/guzzlehttp/promises/src/Promise.php(153): GuzzleHttp\Promise\Promise::callHandler()

6 /var/www/LinkAce/vendor/guzzlehttp/promises/src/TaskQueue.php(48): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()

7 /var/www/LinkAce/vendor/guzzlehttp/promises/src/Promise.php(248): GuzzleHttp\Promise\TaskQueue->run()

8 /var/www/LinkAce/vendor/guzzlehttp/promises/src/Promise.php(224): GuzzleHttp\Promise\Promise->invokeWaitFn()

9 /var/www/LinkAce/vendor/guzzlehttp/promises/src/Promise.php(269): GuzzleHttp\Promise\Promise->waitIfPending()

10 /var/www/LinkAce/vendor/guzzlehttp/promises/src/Promise.php(226): GuzzleHttp\Promise\Promise->invokeWaitList()

11 /var/www/LinkAce/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()

12 /var/www/LinkAce/vendor/guzzlehttp/guzzle/src/Client.php(189): GuzzleHttp\Promise\Promise->wait()

13 /var/www/LinkAce/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(961): GuzzleHttp\Client->request()

14 /var/www/LinkAce/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(823): Illuminate\Http\Client\PendingRequest->sendRequest()

15 /var/www/LinkAce/vendor/laravel/framework/src/Illuminate/Support/helpers.php(247): Illuminate\Http\Client\PendingRequest->Illuminate\Http\Client\{closure}()

16 /var/www/LinkAce/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(821): retry()

17 /var/www/LinkAce/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(699): Illuminate\Http\Client\PendingRequest->send()

18 /var/www/LinkAce/vendor/kovah/laravel-html-meta/src/HtmlMeta.php(60): Illuminate\Http\Client\PendingRequest->get()

19 /var/www/LinkAce/vendor/kovah/laravel-html-meta/src/HtmlMeta.php(36): Kovah\HtmlMeta\HtmlMeta->fetchUrl()

20 /var/www/LinkAce/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(338): Kovah\HtmlMeta\HtmlMeta->forUrl()

21 /var/www/LinkAce/app/Helper/HtmlMeta.php(40): Illuminate\Support\Facades\Facade::__callStatic()

22 /var/www/LinkAce/app/Repositories/LinkRepository.php(31): App\Helper\HtmlMeta->getFromUrl()

23 /var/www/LinkAce/app/Http/Controllers/Models/LinkController.php(76): App\Repositories\LinkRepository::create()

24 /var/www/LinkAce/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): App\Http\Controllers\Models\LinkController->store()

25 /var/www/LinkAce/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(43): Illuminate\Routing\Controller->callAction()

[...]

76 {main}

"}



---

The errors may stem from the same code: `[]` are incorrectly encoded somewhere. Where and why this happens, I don't know how to easily find out. For the first two encoding issues, a solution-by-simplification may be to just use relative URLs instead of trying to add unnecessary details to links, but that would still leave the link adding problem

---

LinkAce version: dev  
Setup Method: PHP  
Operating System: Debian Bookworm
chrissawyerfan4 commented 1 year ago

Forgot to mention: I'll leave that system up for a week or so, so you can see the problem for yourself and we can easily test a fix. I could add an ssh key (one of these? https://github.com/Kovah.keys) if you'd like to poke around yourself

chrissawyerfan4 commented 1 year ago

system pop-up "Type error [while processing hostname] 2a01:4f8:c17:cfd5::1 for browsingData.remove"

Why am I doing this to myself :sob: An add-on to delete cookies after closing the tab now pops an error onto my screen every few minutes. Maybe that's what I had network.dns.disableIPv6 set to enabled in about:config for years ._. The world is clearly not ready for the wonders of IPv6

(Edit: for the record, nothing a little echo "delete from moz_cookies where host like '%4f8:c17:cfd5%';" | sqlite3 ~/.mozilla/*/cookies.sqlite couldn't fix ^^)

Kovah commented 1 year ago

Thanks for the very detailed report. I will have a look at the parsing of URLs containing v6 IPs. But all the other stuff... well you mentioned it: the world is not ready yet. I can't understand how a dominating platform like Github does not support incoming IPv6 traffic...