properly resolve domains in load_url

This commit is contained in:
Izalia Mae 2022-09-01 17:01:29 -04:00
parent ca291b8c1b
commit 7c9ce2f05d
5 changed files with 19 additions and 11 deletions

View file

@ -23,13 +23,13 @@ class WebContext(WebKit2.WebContext):
self.set_spell_checking_enabled(True)
self.set_favicon_database_directory(app.path.favicon)
self.set_web_extensions_directory(app.path.script.join('bin'))
self.set_cache_model(WebKit2.CacheModel(1))
self.set_cache_model(WebKit2.CacheModel.WEB_BROWSER)
self.set_use_system_appearance_for_scrollbars(True)
## Setup Cookie storage
self.cookiemanager = self.get_cookie_manager()
self.cookiemanager.set_persistent_storage(app.path.cookies, WebKit2.CookiePersistentStorage(1))
self.cookiemanager.set_accept_policy(WebKit2.CookieAcceptPolicy(2))
self.cookiemanager.set_persistent_storage(app.path.cookies, WebKit2.CookiePersistentStorage.SQLITE)
self.cookiemanager.set_accept_policy(WebKit2.CookieAcceptPolicy.NO_THIRD_PARTY)
## Register local uri schemes
self.security_manager = self.get_security_manager()
@ -37,6 +37,9 @@ class WebContext(WebKit2.WebContext):
self.security_manager.register_uri_scheme_as_local('bsweb://')
self.security_manager.register_uri_scheme_as_local('local://') #Renamed "file://" handler
self.security_manager.register_uri_scheme_as_secure('oauth://')
self.security_manager.register_uri_scheme_as_no_access(var.local)
self.security_manager.register_uri_scheme_as_no_access('bsweb://')
self.security_manager.register_uri_scheme_as_no_access('oauth://')
## Setup custom protocols
self.register_uri_scheme(var.local_proto, protocol.Local)

View file

@ -2,8 +2,10 @@ import cairo
import threading
from bs4 import BeautifulSoup
from dns.resolver import NXDOMAIN, resolve
from izzylib.exceptions import DNSResolverError
from izzylib.misc import class_name
from izzylib.url import Address
from .web_tab_settings import WebSettings
from .web_tab_webview_handler import WebviewHandler
@ -515,7 +517,7 @@ class WebTab(BuilderBase, Gtk.Box):
## Is the url.domain an actual domain?
if not keyword:
try:
address = url.resolve_hostname(1)
address = Address(resolve(url.domain))
logging.verbose('Url without protocol')
@ -525,7 +527,7 @@ class WebTab(BuilderBase, Gtk.Box):
port = 80 if url.port == 443 else url.port
)
except DNSResolverError:
except NXDOMAIN:
pass
if not address:

View file

@ -16,6 +16,11 @@
"options": [],
"url": null
},
"dnspython": {
"version": "2.2.1",
"options": [],
"url": null
},
"izzylib": {
"version": "0.7.1",
"options": [],
@ -71,11 +76,6 @@
"options": [],
"url": null
},
"smhtml": {
"version": "0.0.1",
"options": [],
"url": "git+https://github.com/ssato/python-smhtml"
},
"watchdog": {
"version": "2.1.9",
"options": [],
@ -105,4 +105,4 @@
"pyvenv.py"
]
}
}
}

View file

@ -1,6 +1,7 @@
beautifulsoup4==4.9.3
click==8.1.0
dasbus==1.6
dnspython==2.2.1
izzylib@git+https://git.barkshark.xyz/izaliamae/izzylib
izzylib-http-async@git+https://git.barkshark.xyz/izaliamae/izzylib-http-async
izzylib-sql@git+https://git.barkshark.xyz/izaliamae/izzylib-sql
@ -12,4 +13,5 @@ psutil==5.8.0
pygobject==3.38.0
pysftp==0.2.9
secretstorage==3.3.2
smhtml@git+https://github.com/ssato/python-smhtml
watchdog==2.1.9

View file

@ -36,6 +36,7 @@ setup_requires =
beautifulsoup4==4.9.3
click==8.1.0
dasbus==1.6
dnspython==2.2.1
izzylib@git+https://git.barkshark.xyz/izaliamae/izzylib
izzylib-http-async@git+https://git.barkshark.xyz/izaliamae/izzylib-http-async
izzylib-sql@git+https://git.barkshark.xyz/izaliamae/izzylib-sql