Compare commits

...

2 Commits

Author SHA1 Message Date
Fierelier 7730d2af3e Bump version 2021-03-25 20:58:33 +01:00
Fierelier c4d2463372 Add setting for default charset 2021-03-25 20:58:22 +01:00
2 changed files with 7 additions and 5 deletions

View File

@ -5,6 +5,8 @@ home = https://example.com
useragent = BirdyNet/$VER ($OS)
# Which protocol to use when none is given in the address bar
defaultProtocol = https
# Which charset to use when none is given in the header. https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7.1 defines that iso-8859-1 should be used. You may also use utf-8 though, if it's better for the pages you visit.
defaultCharset = iso-8859-1
[accessibility]
# Which background color (CSS color) should be chosen for websites? "default" for system's default. "white" is recommended for compatibility.

View File

@ -34,8 +34,8 @@ os.chdir(sp)
distro = os.path.splitext(s.rsplit(os.path.sep)[-1])[0]
version = {
"major": 0,
"minor": 8,
"patch": 1,
"minor": 9,
"patch": 0,
"stage": "dev"
}
versionString = ".".join(map(str,[version["major"],version["minor"]]))
@ -188,14 +188,14 @@ class browserWindow(QMainWindow):
htm = response["body"]
contentType, contentTypeArguments = getContentType(response["headers"],"text")
if not "charset" in contentTypeArguments: contentTypeArguments["charset"] = "utf-8"
if not "charset" in contentTypeArguments: contentTypeArguments["charset"] = config["default"]["defaultCharset"]
print("content-type: " +contentType+ "\n" +prettyJson(contentTypeArguments))
try:
htm = htm.decode(contentTypeArguments["charset"],errors="ignore")
except Exception as e:
print("decoding html as '" +contentTypeArguments["charset"]+ "' failed, trying utf-8...")
htm = htm.decode("utf-8",errors="ignore")
print("decoding html as '" +contentTypeArguments["charset"]+ "' failed, trying " +config["default"]["defaultCharset"]+ "...")
htm = htm.decode(config["default"]["defaultCharset"],errors="ignore")
self.cDoc.cRenderHtml(htm,contentType)
end = time.time()