Skip to content

Commit

Permalink
sanitize URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
bengl committed Aug 4, 2023
1 parent 5ac01d7 commit 2531cdd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function createHook (meta) {
return {
source: `
import { register } from '${iitmURL}'
import * as namespace from '${url}'
import * as namespace from ${JSON.stringify(url)}
const set = {}
${exportNames.map((n) => `
let $${n} = namespace.${n}
Expand All @@ -132,7 +132,7 @@ set.${n} = (v) => {
return true
}
`).join('\n')}
register('${realUrl}', namespace, set, '${specifiers.get(realUrl)}')
register(${JSON.stringify(realUrl)}, namespace, set, ${JSON.stringify(specifiers.get(realUrl))})
`
}
}
Expand Down
11 changes: 11 additions & 0 deletions test/low-level/sanitized-url.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2.0 License.
//
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021 Datadog, Inc.

import { addHook } from '../../index.js'

addHook(() => {})

;(async () => {
await import("../fixtures/something.mjs#*/'/*';eval('process.exit\x281\x29\x0A')")
})()

0 comments on commit 2531cdd

Please sign in to comment.