From 03f86acd60655cf73a8f52dbe503df71e9d2b718 Mon Sep 17 00:00:00 2001
From: William Chong <williamchong007@msn.com>
Date: Tue, 5 Dec 2017 19:25:35 +0800
Subject: fix #1398, prevent injecting xml without xml suffix

---
 app/scripts/contentscript.js | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

(limited to 'app/scripts/contentscript.js')

diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js
index ffbbc73cc..2ed7c87b6 100644
--- a/app/scripts/contentscript.js
+++ b/app/scripts/contentscript.js
@@ -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'
-- 
cgit