face-hh / webx

An alternative for the World Wide Web - browse websites such as buss://yippie.rizz made in HTML, CSS and Lua. Custom web browser, custom HTML rendering engine, custom search engine, and more.
Apache License 2.0
1.84k stars 155 forks source link

BUG: Not fetching html from server IP #187

Open Nocturnalx opened 3 months ago

Nocturnalx commented 3 months ago

Describe the bug After fetching a standalone IP from the DNS lookup and passing it to build_ui()->parse_html()->fetch_file(), the reqwest::get() causes an error if the IP does not specify http://.

To Reproduce

  1. register domain name to an IP address without adding http:// before hand
  2. attempt to access registered domain via the url input

Expected behavior Browser and/or DNS server should ensure "http://" is added to the address before performing any kind of fetch on it to prevent an error from reqwest.

Desktop (please complete the following information): Arch linux reqwest version 0.12.3

Additional context I have a very simple check ready to PR for if the returned json.ip can be parsed as a standalone IP within fetch_dns() (main.rs:584), but that should really only be done after the DNS has been normalised to either return or not return the http:// prefix on lookup. https://github.com/face-hh/webx/commit/e22cac904ce141d33a3619a5f0313136d47ecc28

Also i noticed Url::parse() (html.rs: parse_html(): line 34) breaks on a standalone IP not being a readable url so never appends index.html but this is just the same problem of a lack of http:// as the fetch issue.

Nocturnalx commented 3 months ago

I can confirm changing the domain registration url to include "http://" before the IP fixed the issue when accessing with the current master branch release, I also noticed that the prompt does say to just input the IP as a standalone IP.