Skip to content

Commit

Permalink
feat: 馃幐 don't use innerhtml when passing a string
Browse files Browse the repository at this point in the history
BREAKING CHANGE: When providing a string as content, we use innertext instead to prevent
xss
  • Loading branch information
NetanelBasal committed Jul 15, 2021
1 parent 1e33a89 commit cb4f2f7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ testem.log
# System Files
.DS_Store
Thumbs.db
cypress/screenshots
3 changes: 3 additions & 0 deletions projects/ngneat/helipopper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"tippy.js": "^6.2.3",
"tslib": "^2.0.0"
},
"peerDependencies": {
"@ngneat/overview": "*"
},
"keywords": [
"angular",
"angular tooltip",
Expand Down
4 changes: 4 additions & 0 deletions projects/ngneat/helipopper/src/lib/tippy.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ export class TippyDirective implements OnChanges, AfterViewInit, OnDestroy, OnIn
},
onShow: instance => {
this.zone.run(() => {
const content = this.resolveContent();
if (isString(content)) {
instance.setProps({ allowHTML: false });
}
instance.setContent(this.resolveContent());
this.hideOnEscape && this.handleEscapeButton();
});
Expand Down
13 changes: 13 additions & 0 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -273,3 +273,16 @@ <h6>Menu</h6>
</div>
</div>
</ng-container>

<div>
<h6>Sanitize</h6>

<input
style="max-width: 600px"
type="text"
placeholder="Sanitize"
tippy="<img src='empty.gif' onerror='alert(1);' />"
/>
</div>

<hr />

0 comments on commit cb4f2f7

Please sign in to comment.