Skip to content

Commit 6f98ba2

Browse files
committed
检查sourceMaps的合法性
1 parent 0c8fd77 commit 6f98ba2

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

extension/js/configurationProvider.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ function resolveLaunchConfig(config, platname, settings) {
169169
else if (typeof config.cpath == 'object') {
170170
}
171171
else {
172-
let ext = platname == "windows"? "dll" : "so"
172+
let ext = platname == "windows" ? "dll" : "so"
173173
config.cpath = ['${cwd}/?.' + ext]
174174
if (typeof config.luaexe == 'string') {
175175
config.cpath.push(path.dirname(config.luaexe) + '/?.' + ext)
@@ -219,7 +219,7 @@ function resolveConfig(folder, config) {
219219
if (typeof config.name != 'string') {
220220
config.name = 'Not specified';
221221
}
222-
config.workspaceFolder = folder? folder.uri.fsPath: undefined;
222+
config.workspaceFolder = folder ? folder.uri.fsPath : undefined;
223223
if (typeof config.cwd != 'string') {
224224
if (!config.workspaceFolder) {
225225
throw new Error('The `cwd` can not be resolved in a multi folder workspace.\n\tSolution: "cwd" : "${workspaceFolder:name}" ');
@@ -265,6 +265,16 @@ function resolveConfig(folder, config) {
265265
config.pathFormat = "path"
266266
}
267267
}
268+
if (Array.isArray(config.sourceMaps)) {
269+
for (const sourceMap of config.sourceMaps) {
270+
if (!Array.isArray(sourceMap) || sourceMap.length != 2) {
271+
throw new Error('Invalid sourceMaps.');
272+
}
273+
}
274+
}
275+
else {
276+
config.sourceMaps = undefined;
277+
}
268278
if (config.request == 'launch') {
269279
resolveLaunchConfig(config, platname, settings)
270280
}
@@ -284,7 +294,7 @@ exports.resolve = {
284294
resolveDebugConfiguration: async function (folder, config) {
285295
try {
286296
return resolveConfig(folder, config);
287-
} catch (err) {
297+
} catch (err) {
288298
let action = await vscode.window.showErrorMessage(
289299
err.message,
290300
{ modal: true },

0 commit comments

Comments
 (0)