t2ym / thin-hook

Thin Hook Preprocessor
Other
4 stars 1 forks source link

[webcomponentsjs html-imports][Firefox] Inline scripts are lost in HTML imports #182

Open t2ym opened 6 years ago

t2ym commented 6 years ago

[webcomponentsjs html-imports][Firefox] Inline scripts are lost in HTML imports

Root Cause

Notes

t2ym commented 6 years ago

[NEVER APPLY IT except for ACL verification] Patch to open SECURITY HOLES to temporarily force the web components polyfills to work on Firefox merely for ad-hoc ACL verification

diff --git a/lib/native-wrapper.js b/lib/native-wrapper.js
index 89f1fc3..b4e0aef 100644
--- a/lib/native-wrapper.js
+++ b/lib/native-wrapper.js
@@ -320,7 +320,12 @@ module.exports = function (hook, preprocess) {
               if (_value) {
                 let srcUrl = new URL(_value, 'https://localhost/');
                 if (!srcUrl.pathname.match(/[.]m?js$/)) {
-                  value = ''; // invalid script source path
+                  if (srcUrl.protocol === 'data:' && _value.startsWith('data:text/javascript')) {
+                    console.log('setAttribute("src", "data:text/javascript")');
+                  }
+                  else {
+                    value = ''; // invalid script source path
+                  }
                 }
               }
             }
@@ -353,7 +358,7 @@ module.exports = function (hook, preprocess) {
         enumerable: _nativeMethods.Element.proto.innerHTML.enumerable,
         get: _nativeMethods.Element.proto.innerHTML.get,
         set: function (value) {
-          let processed = preprocess._preprocessHtml(
+          let processed = value.indexOf('__hook__') >= 0 ? value : preprocess._preprocessHtml(
             value,
             hookName,
             new URL(document.location),

Security Holes with this patch

t2ym commented 6 years ago

Issue