Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
9d0e61d0
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
9d0e61d0
编写于
8月 26, 2019
作者:
P
Pine
提交者:
GitHub
8月 26, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #79838 from microsoft/pine/link-improvement
Improve link protection
上级
e4ea93b8
383b36f7
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
39 addition
and
24 deletion
+39
-24
src/vs/platform/product/common/product.ts
src/vs/platform/product/common/product.ts
+1
-0
src/vs/workbench/contrib/url/common/url.contribution.ts
src/vs/workbench/contrib/url/common/url.contribution.ts
+38
-24
未找到文件。
src/vs/platform/product/common/product.ts
浏览文件 @
9d0e61d0
...
...
@@ -87,6 +87,7 @@ export interface IProductConfiguration {
};
readonly
portable
?:
string
;
readonly
uiExtensions
?:
readonly
string
[];
readonly
linkProtectionTrustedDomains
?:
readonly
string
[];
}
export
interface
IExeBasedExtensionTip
{
...
...
src/vs/workbench/contrib/url/common/url.contribution.ts
浏览文件 @
9d0e61d0
...
...
@@ -50,29 +50,20 @@ Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions).registe
localize
(
'
developer
'
,
'
Developer
'
)
);
const
DEAFULT_TRUSTED_DOMAINS
=
[
'
https://code.visualstudio.com
'
,
'
https://go.microsoft.com
'
,
'
https://github.com
'
,
'
https://marketplace.visualstudio.com
'
,
'
https://vscode-auth.github.com
'
];
const
configureTrustedDomainsHandler
=
async
(
quickInputService
:
IQuickInputService
,
storageService
:
IStorageService
,
linkProtectionTrustedDomains
:
string
[],
domainToConfigure
?:
string
)
=>
{
let
trustedDomains
:
string
[]
=
DEAFULT_TRUSTED_DOMAINS
;
try
{
const
trustedDomainsSrc
=
storageService
.
get
(
'
http.
t
rustedDomains
'
,
StorageScope
.
GLOBAL
);
const
trustedDomainsSrc
=
storageService
.
get
(
'
http.
linkProtectionT
rustedDomains
'
,
StorageScope
.
GLOBAL
);
if
(
trustedDomainsSrc
)
{
t
rustedDomains
=
JSON
.
parse
(
trustedDomainsSrc
);
linkProtectionT
rustedDomains
=
JSON
.
parse
(
trustedDomainsSrc
);
}
}
catch
(
err
)
{
}
const
domainQuickPickItems
:
IQuickPickItem
[]
=
t
rustedDomains
const
domainQuickPickItems
:
IQuickPickItem
[]
=
linkProtectionT
rustedDomains
.
filter
(
d
=>
d
!==
'
*
'
)
.
map
(
d
=>
{
return
{
...
...
@@ -88,12 +79,12 @@ const configureTrustedDomainsHandler = async (
type
:
'
item
'
,
label
:
localize
(
'
openAllLinksWithoutPrompt
'
,
'
Open all links without prompt
'
),
id
:
'
*
'
,
picked
:
t
rustedDomains
.
indexOf
(
'
*
'
)
!==
-
1
picked
:
linkProtectionT
rustedDomains
.
indexOf
(
'
*
'
)
!==
-
1
}
];
let
domainToConfigureItem
:
IQuickPickItem
|
undefined
=
undefined
;
if
(
domainToConfigure
&&
t
rustedDomains
.
indexOf
(
domainToConfigure
)
===
-
1
)
{
if
(
domainToConfigure
&&
linkProtectionT
rustedDomains
.
indexOf
(
domainToConfigure
)
===
-
1
)
{
domainToConfigureItem
=
{
type
:
'
item
'
,
label
:
domainToConfigure
,
...
...
@@ -116,7 +107,7 @@ const configureTrustedDomainsHandler = async (
if
(
pickedResult
)
{
const
pickedDomains
:
string
[]
=
pickedResult
.
map
(
r
=>
r
.
id
!
);
storageService
.
store
(
'
http.
t
rustedDomains
'
,
JSON
.
stringify
(
pickedDomains
),
StorageScope
.
GLOBAL
);
storageService
.
store
(
'
http.
linkProtectionT
rustedDomains
'
,
JSON
.
stringify
(
pickedDomains
),
StorageScope
.
GLOBAL
);
return
pickedDomains
;
}
...
...
@@ -125,16 +116,26 @@ const configureTrustedDomainsHandler = async (
};
const
configureTrustedDomainCommand
=
{
id
:
'
workbench.action.configureTrustedDomains
'
,
id
:
'
workbench.action.configure
LinkProtection
TrustedDomains
'
,
description
:
{
description
:
localize
(
'
configure
TrustedDomains
'
,
'
Configure Trusted Domains
'
),
description
:
localize
(
'
configure
LinkProtectionTrustedDomains
'
,
'
Configure Trusted Domains for Link Protection
'
),
args
:
[{
name
:
'
domainToConfigure
'
,
schema
:
{
type
:
'
string
'
}
}]
},
handler
:
(
accessor
:
ServicesAccessor
,
domainToConfigure
?:
string
)
=>
{
const
quickInputService
=
accessor
.
get
(
IQuickInputService
);
const
storageService
=
accessor
.
get
(
IStorageService
);
const
productService
=
accessor
.
get
(
IProductService
);
return
configureTrustedDomainsHandler
(
quickInputService
,
storageService
,
domainToConfigure
);
const
trustedDomains
=
productService
.
linkProtectionTrustedDomains
?
[...
productService
.
linkProtectionTrustedDomains
]
:
[];
return
configureTrustedDomainsHandler
(
quickInputService
,
storageService
,
trustedDomains
,
domainToConfigure
);
}
};
...
...
@@ -164,9 +165,12 @@ class OpenerValidatorContributions implements IWorkbenchContribution {
return
true
;
}
let
trustedDomains
:
string
[]
=
DEAFULT_TRUSTED_DOMAINS
;
let
trustedDomains
:
string
[]
=
this
.
_productService
.
linkProtectionTrustedDomains
?
[...
this
.
_productService
.
linkProtectionTrustedDomains
]
:
[];
try
{
const
trustedDomainsSrc
=
this
.
_storageService
.
get
(
'
http.
t
rustedDomains
'
,
StorageScope
.
GLOBAL
);
const
trustedDomainsSrc
=
this
.
_storageService
.
get
(
'
http.
linkProtectionT
rustedDomains
'
,
StorageScope
.
GLOBAL
);
if
(
trustedDomainsSrc
)
{
trustedDomains
=
JSON
.
parse
(
trustedDomainsSrc
);
}
...
...
@@ -174,7 +178,9 @@ class OpenerValidatorContributions implements IWorkbenchContribution {
const
domainToOpen
=
`
${
scheme
}
://
${
authority
}
`
;
if
(
isDomainTrusted
(
domainToOpen
,
trustedDomains
))
{
if
(
isLocalhostAuthority
(
authority
))
{
return
true
;
}
else
if
(
isDomainTrusted
(
domainToOpen
,
trustedDomains
))
{
return
true
;
}
else
{
const
choice
=
await
this
.
_dialogService
.
show
(
...
...
@@ -201,7 +207,7 @@ class OpenerValidatorContributions implements IWorkbenchContribution {
}
// Configure Trusted Domains
else
if
(
choice
===
2
)
{
const
pickedDomains
=
await
configureTrustedDomainsHandler
(
this
.
_quickInputService
,
this
.
_storageService
,
domainToOpen
);
const
pickedDomains
=
await
configureTrustedDomainsHandler
(
this
.
_quickInputService
,
this
.
_storageService
,
trustedDomains
,
domainToOpen
);
if
(
pickedDomains
.
indexOf
(
domainToOpen
)
!==
-
1
)
{
return
true
;
}
...
...
@@ -218,6 +224,13 @@ Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).regi
LifecyclePhase
.
Restored
);
const
rLocalhost
=
/^localhost:
\d
+$/i
;
const
r127
=
/^127.0.0.1:
\d
+$/
;
function
isLocalhostAuthority
(
authority
:
string
)
{
return
rLocalhost
.
test
(
authority
)
||
r127
.
test
(
authority
);
}
/**
* Check whether a domain like https://www.microsoft.com matches
* the list of trusted domains.
...
...
@@ -235,3 +248,4 @@ function isDomainTrusted(domain: string, trustedDomains: string[]) {
return
false
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录