1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00

Merge pull request #2662 from williamchong007/master

fix #1398, prevent injecting xml without xml suffix
This commit is contained in:
Thomas Huang 2017-12-14 14:34:21 -05:00 committed by GitHub
commit fb5edfe69e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -96,7 +96,7 @@ function logStreamDisconnectWarning (remoteLabel, err) {
}
function shouldInjectWeb3 () {
return doctypeCheck() || suffixCheck()
return doctypeCheck() && suffixCheck() && documentElementCheck()
}
function doctypeCheck () {
@ -104,7 +104,7 @@ function doctypeCheck () {
if (doctype) {
return doctype.name === 'html'
} else {
return false
return true
}
}
@ -121,6 +121,14 @@ function suffixCheck () {
return true
}
function documentElementCheck () {
var documentElement = document.documentElement.nodeName
if (documentElement) {
return documentElement.toLowerCase() === 'html'
}
return true
}
function redirectToPhishingWarning () {
console.log('MetaMask - redirecting to phishing warning')
window.location.href = 'https://metamask.io/phishing.html'