Skip to content

Commit

Permalink
openUrl: add a warning for file:/// and about: URLs on Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
gdh1995 committed Feb 16, 2024
1 parent 8065102 commit 5280f9f
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion background/open_urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
convertToUrl_, createSearchUrl_, hasUsedKeyword_, lastUrlType_, quotedStringRe_, reformatURL_
} from "./normalize_urls"
import { findUrlEndingWithPunctuation_, findUrlInText_ } from "./parse_urls"
import { safePost, showHUD, complainLimits, findCPort, isNotVomnibarPage, getCurFrames_ } from "./ports"
import { safePost, showHUD, complainLimits, findCPort, isNotVomnibarPage, getCurFrames_, showHUDEx } from "./ports"
import { createSimpleUrlMatcher_, matchSimply_ } from "./exclusions"
import { trans_ } from "./i18n"
import { makeCommand_ } from "./key_mappings"
Expand Down Expand Up @@ -594,6 +594,8 @@ export const openUrlWithActions = (url: Urls.Url, workType: Urls.WorkType, sed?:
reuse = reuse !== ReuseType.newBg ? ReuseType.newFg : reuse
}
if (incog != null && incog !== (curIncognito_ === IncognitoType.true)) { reuse = ReuseType.newFg }
OnFirefox && typeof url === "string" && cPort && (<RegExpOne> /^file:|^about:(?!blank)/).test(url)
&& options.warnFiles !== false && showHUDEx(cPort, "disabledUrlToOpen", 2, [])
typeof url !== "string"
? void Promise.resolve(url).then(onEvalUrl_.bind(0, workType, options, tabs))
: /*#__NOINLINE__*/ openShowPage(url, reuse, options) ? 0
Expand Down
1 change: 1 addition & 0 deletions i18n/en/background.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"copiedWndInfo": "(info of tabs)",
"csCleared": "$1 content settings have been cleared",
"delSug": "Succeed to delete a $1",
"disabledUrlToOpen": "Extensions can't open such URLs on Firefox",
"discardFail": "Cannot discard the tab",
"downloadFail": "Failed in downloading",
"downloadTimeout": "Downloading took too long",
Expand Down
1 change: 1 addition & 0 deletions i18n/fr/background.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"copiedWndInfo": "(info des onglets)",
"csCleared": "Les paramètres du contenu $1 ont été effacés",
"delSug": "A réussi à supprimer un $1",
"disabledUrlToOpen": "Firefox n'autorise pas l'extension à ouvrir cette URL",
"discardFail": "Ne peut pas décharger l'onglet",
"downloadFail": "Échec du téléchargement",
"downloadTimeout": "Le téléchargement a pris trop de temps",
Expand Down
1 change: 1 addition & 0 deletions i18n/zh/background.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"copiedWndInfo": "(标签页信息)",
"csCleared": "对各网站 $1 功能权限的修改已重置",
"delSug": "成功删除所选$1",
"disabledUrlToOpen": "Firefox 不允许扩展打开此网址",
"discardFail": "无法丢弃此网页",
"downloadFail": "无法下载此对象",
"downloadTimeout": "对象下载超时",
Expand Down
1 change: 1 addition & 0 deletions i18n/zh_TW/background.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"copiedWndInfo": "(分頁信息)",
"csCleared": "對各網站 $1 功能權限的修改已重置",
"delSug": "成功刪除所選$1",
"disabledUrlToOpen": "Firefox 不允許擴展存取此網址",
"discardFail": "無法丟棄此網頁",
"downloadFail": "無法下載此對象",
"downloadTimeout": "對象下載超時",
Expand Down
1 change: 1 addition & 0 deletions typings/messages.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ interface OpenUrlOptions extends UserSedOptions {
| "default"
reuse?: UserReuseType | null
window?: boolean | "popup" | "normal" | null
warnFiles?: true | false | null
}

interface OpenPageUrlOptions extends OpenUrlOptions {
Expand Down

0 comments on commit 5280f9f

Please sign in to comment.