Skip to content

Commit

Permalink
fix: sanitize alert string
Browse files Browse the repository at this point in the history
  • Loading branch information
moughxyz committed Feb 2, 2022
1 parent 616b77a commit 333d4c4
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions app/assets/javascripts/services/alertService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* eslint-disable prefer-promise-reject-errors */
import { SNAlertService, ButtonType } from '@standardnotes/snjs';
import {
SNAlertService,
ButtonType,
sanitizeHtmlString,
} from '@standardnotes/snjs';
import { SKAlert } from 'sn-stylekit';

/** @returns a promise resolving to true if the user confirmed, false if they canceled */
Expand All @@ -18,8 +22,8 @@ export function confirmDialog({
}) {
return new Promise<boolean>((resolve) => {
const alert = new SKAlert({
title,
text,
title: title && sanitizeHtmlString(title),
text: sanitizeHtmlString(text),
buttons: [
{
text: cancelButtonText,
Expand Down Expand Up @@ -52,8 +56,8 @@ export function alertDialog({
}) {
return new Promise<void>((resolve) => {
const alert = new SKAlert({
title,
text,
title: title && sanitizeHtmlString(title),
text: sanitizeHtmlString(text),
buttons: [
{
text: closeButtonText,
Expand Down Expand Up @@ -92,7 +96,10 @@ export class AlertService implements SNAlertService {
}

blockingDialog(text: string, title?: string) {
const alert = new SKAlert({ text, title });
const alert = new SKAlert({
title: title && sanitizeHtmlString(title),
text: sanitizeHtmlString(text),
});
alert.present();
return () => {
alert.dismiss();
Expand Down

0 comments on commit 333d4c4

Please sign in to comment.