beta release build 0.7.2

This commit is contained in:
刘浩远 2020-08-13 10:50:15 +08:00
parent 31b13aa943
commit af5fd44ef9
4 changed files with 10 additions and 5 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "fluent-reader",
"version": "0.7.1",
"version": "0.7.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "fluent-reader",
"version": "0.7.1",
"version": "0.7.2",
"description": "Modern desktop RSS reader",
"main": "./dist/electron.js",
"scripts": {

View File

@ -60,6 +60,7 @@ export class WindowManager {
webviewTag: true,
enableRemoteModule: false,
contextIsolation: true,
worldSafeExecuteJavaScript: true,
spellcheck: false,
preload: path.join(app.getAppPath(), (app.isPackaged ? "dist/" : "") + "preload.js")
}

View File

@ -29,18 +29,22 @@ const rssParser = new Parser({
})
const CHARSET_RE = /charset=([^()<>@,;:\"/[\]?.=\s]*)/i
const XML_ENCODING_RE = /^<\?xml.+encoding="(.+)".*\?>\s*\n/i
const XML_ENCODING_RE = /^<\?xml.+encoding="(.+)".*?\?>/i
export async function decodeFetchResponse(response: Response, isHTML = false) {
const buffer = await response.arrayBuffer()
const ctype = response.headers.has("content-type") && response.headers.get("content-type")
let ctype = response.headers.has("content-type") && response.headers.get("content-type")
let charset = (ctype && CHARSET_RE.test(ctype)) ? CHARSET_RE.exec(ctype)[1] : undefined
let content = (new TextDecoder(charset)).decode(buffer)
if (charset === undefined) {
if (isHTML) {
const dom = domParser.parseFromString(content, "text/html")
charset = dom.querySelector("meta[charset]")?.getAttribute("charset")?.toLowerCase()
if (!charset) {
ctype = dom.querySelector("meta[http-equiv='Content-Type']")?.getAttribute("content")
charset = ctype && CHARSET_RE.test(ctype) && CHARSET_RE.exec(ctype)[1].toLowerCase()
}
} else {
charset = (XML_ENCODING_RE.test(content) && XML_ENCODING_RE.exec(content)[1])?.toLowerCase()
charset = XML_ENCODING_RE.test(content) && XML_ENCODING_RE.exec(content)[1].toLowerCase()
}
if (charset && charset !== "utf-8" && charset !== "utf8") {
content = (new TextDecoder(charset)).decode(buffer)