Skip to content

Commit

Permalink
refactor(security): mark potential unsafe code paths
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Feb 12, 2020
1 parent 8b7c162 commit 8e19424
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/runtime-dom/src/modules/props.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// __UNSAFE__
// Reason: potentially setting innerHTML.
// This can come from explicit usage of v-html or innerHTML as a prop in render
// functions. The user is reponsible for using them with only trusted content.
export function patchDOMProp(
el: any,
key: string,
Expand Down
4 changes: 4 additions & 0 deletions packages/runtime-dom/src/nodeOps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ export const nodeOps: Omit<RendererOptions<Node, Element>, 'patchProp'> = {
return el.cloneNode(true)
},

// __UNSAFE__
// Reason: innerHTML.
// Static content here can only come from compiled templates.
// As long as the user only uses trusted templates, this is safe.
insertStaticContent(content, parent, anchor, isSVG) {
const temp = isSVG
? tempSVGContainer ||
Expand Down
4 changes: 4 additions & 0 deletions packages/vue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ function compileToFunction(
if (__DEV__ && !el) {
warn(`Template element not found or is empty: ${template}`)
}
// __UNSAFE__
// Reason: potential execution of JS expressions in in-DOM template.
// The user must make sure the in-DOM template is trusted. If it's rendered
// by the server, the template should not contain any user data.
template = el ? el.innerHTML : ``
}

Expand Down

0 comments on commit 8e19424

Please sign in to comment.