From 30df1e7f2b7c0b54834032c0b9a8c360a0897814 Mon Sep 17 00:00:00 2001
From: Li Yi Yu
Date: Thu, 9 Nov 2023 15:37:33 -0500
Subject: [PATCH] fix(surveys): allow target attributes for html (#18532)
---
.../src/scenes/surveys/SurveyAppearance.tsx | 20 ++++++++++---------
frontend/src/scenes/surveys/utils.ts | 7 +++++++
2 files changed, 18 insertions(+), 9 deletions(-)
create mode 100644 frontend/src/scenes/surveys/utils.ts
diff --git a/frontend/src/scenes/surveys/SurveyAppearance.tsx b/frontend/src/scenes/surveys/SurveyAppearance.tsx
index 27f593a273ccc..3f1fa5c4074b7 100644
--- a/frontend/src/scenes/surveys/SurveyAppearance.tsx
+++ b/frontend/src/scenes/surveys/SurveyAppearance.tsx
@@ -23,8 +23,8 @@ import {
import { surveysLogic } from './surveysLogic'
import { useValues } from 'kea'
import React, { useEffect, useRef, useState } from 'react'
-import { sanitize } from 'dompurify'
import { PayGateMini } from 'lib/components/PayGateMini/PayGateMini'
+import { sanitizeHTML } from './utils'
interface SurveyAppearanceProps {
type: SurveyQuestionType
@@ -284,12 +284,12 @@ export function BaseAppearance({
)}
-
+
{/* Using dangerouslySetInnerHTML is safe here, because it's taking the user's input and showing it to the same user.
They can try passing in arbitrary scripts, but it would show up only for them, so it's like trying to XSS yourself, where
you already have all the data. Furthermore, sanitization should catch all obvious attempts */}
{description && (
-
+
)}
{type === SurveyQuestionType.Open && (
)}
-
+
{description && (
-
+
)}
@@ -591,9 +591,9 @@ export function SurveyMultipleChoiceAppearance({