1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 01:39:44 +01:00

Merge pull request #736 from MetaMask/i735-xmlfix

Prevent injections on XML
This commit is contained in:
Dan Finlay 2016-10-17 10:31:15 -07:00 committed by GitHub
commit 6d4c685636
2 changed files with 15 additions and 2 deletions

View File

@ -2,6 +2,7 @@
## Current Master
- Fix bug where web3 was being injected into XML files.
- Add a custom transaction fee field to send form.
## 2.13.3 2016-10-4

View File

@ -69,6 +69,18 @@ function setupStreams(){
}
function shouldInjectWeb3(){
var shouldInject = (window.location.href.indexOf('.pdf') === -1)
return shouldInject
return isAllowedSuffix(window.location.href)
}
function isAllowedSuffix(testCase) {
var prohibitedTypes = ['xml', 'pdf']
var currentUrl = window.location.href
var currentRegex
for (let i = 0; i < prohibitedTypes.length; i++) {
currentRegex = new RegExp(`\.${prohibitedTypes[i]}$`)
if (currentRegex.test(currentUrl)) {
return false
}
}
return true
}