From 0cd076dd4f57ad082d541b69086bd4c8d5a3331d Mon Sep 17 00:00:00 2001
From: Michael Liao <michael.liao@microsoft.com>
Date: Tue, 22 Jun 2021 12:36:00 -0700
Subject: [PATCH] [Bug Fix]: Updating webview CSP + webpack sourcemapping
 overrides (#423)

* [Bug Fix]: Updating webview CSP + webpack sourcemapping overrides

* Updating more sourcemap override locations
---
 examples/sourcemaps.md | 10 +++++++---
 package.json           |  3 +++
 src/devtoolsPanel.ts   |  2 +-
 src/utils.ts           |  1 +
 test/utils.test.ts     |  3 ++-
 5 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/examples/sourcemaps.md b/examples/sourcemaps.md
index caba835d..0e3f0d96 100644
--- a/examples/sourcemaps.md
+++ b/examples/sourcemaps.md
@@ -13,6 +13,7 @@ Note: These are the mappings that are included by default out of the box, with e
     "webpack:///./*": "${webRoot}/*",
     "webpack:///*": "*",
     "webpack:///src/*": "${webRoot}/*",
+     "webpack://*": "${webRoot}/*",
     "meteor://💻app/*": "${webRoot}/*"
 }
 ```
@@ -26,15 +27,18 @@ See the following examples for each entry in the default mappings (`webRoot = /U
 Example:
 "webpack:///./~/querystring/index.js"
 -> "/Users/me/project/node_modules/querystring/index.js"
-"webpack:///./*":   "${webRoot}/*" 
+"webpack:///./*":   "${webRoot}/*"
 Example:
 "webpack:///./src/app.js" -> "/Users/me/project/src/app.js"
-"webpack:///*": "*" 
+"webpack:///*": "*"
 Example:
 "webpack:///project/app.ts" -> "/project/app.ts"
-"webpack:///src/*": "${webRoot}/*" 
+"webpack:///src/*": "${webRoot}/*"
 Example:
 "webpack:///src/app.js" -> "/Users/me/project/app.js"
+"webpack://*": "${webRoot}/*"
+Example:
+"webpack://src/app.js" -> "/Users/me/project/src/app.js"
 "meteor://💻app/*": "${webRoot}/*"
 Example:
 "meteor://💻app/main.ts"` -> `"/Users/me/project/main.ts"
diff --git a/package.json b/package.json
index 6724a4d8..1d8c7722 100644
--- a/package.json
+++ b/package.json
@@ -180,6 +180,7 @@
                         "webpack:///src/*": "${webRoot}/*",
                         "webpack:///*": "*",
                         "webpack:///./~/*": "${webRoot}/node_modules/*",
+                        "webpack://*": "${webRoot}/*",
                         "meteor://💻app/*": "${webRoot}/*"
                     }
                 },
@@ -335,6 +336,7 @@
                                     "webpack:///src/*": "${webRoot}/*",
                                     "webpack:///*": "*",
                                     "webpack:///./~/*": "${webRoot}/node_modules/*",
+                                    "webpack://*": "${webRoot}/*",
                                     "meteor://💻app/*": "${webRoot}/*"
                                 }
                             },
@@ -417,6 +419,7 @@
                                     "webpack:///src/*": "${webRoot}/*",
                                     "webpack:///*": "*",
                                     "webpack:///./~/*": "${webRoot}/node_modules/*",
+                                    "webpack://*": "${webRoot}/*",
                                     "meteor://💻app/*": "${webRoot}/*"
                                 }
                             },
diff --git a/src/devtoolsPanel.ts b/src/devtoolsPanel.ts
index 92aa6894..745d0e62 100644
--- a/src/devtoolsPanel.ts
+++ b/src/devtoolsPanel.ts
@@ -342,7 +342,7 @@ export class DevToolsPanel {
                     style-src 'self' 'unsafe-inline' ${this.panel.webview.cspSource};
                     script-src 'self' 'unsafe-eval' ${this.panel.webview.cspSource};
                     frame-src 'self' ${this.panel.webview.cspSource};
-                    connect-src 'self' ${this.panel.webview.cspSource};
+                    connect-src 'self' data: ${this.panel.webview.cspSource};
                 ">
                 <meta name="referrer" content="no-referrer">
                 <link href="${stylesUri}" rel="stylesheet"/>
diff --git a/src/utils.ts b/src/utils.ts
index 90c794f0..dad6c97d 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -90,6 +90,7 @@ export const SETTINGS_DEFAULT_PATH_OVERRIDES: IStringDictionary<string> = {
     'webpack:///./*': '${webRoot}/*',
     'webpack:///./~/*': '${webRoot}/node_modules/*',
     'webpack:///src/*': '${webRoot}/*',
+    'webpack://*': '${webRoot}/*',
 };
 export const SETTINGS_DEFAULT_WEB_ROOT = '${workspaceFolder}';
 export const SETTINGS_DEFAULT_SOURCE_MAPS = true;
diff --git a/test/utils.test.ts b/test/utils.test.ts
index a2319009..ecbb16ab 100644
--- a/test/utils.test.ts
+++ b/test/utils.test.ts
@@ -706,7 +706,8 @@ describe("utils", () => {
                 "webpack:///./*": `${testPath}\\*`,
                 "webpack:///./~/*": `${testPath}\\node_modules\\*`,
                 "webpack:///*": "*",
-                "webpack:///src/*": `${testPath}\\*`
+                "webpack:///src/*": `${testPath}\\*`,
+                "webpack://*": `${testPath}\\*`
             };
 
             // Ensure the new values are returned