Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/react-native/src/components/survey-web-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,15 @@ const renderHtml = (
`;
}

// Escape "<" so survey content can't inject "</script>" (or "<script"/"<!--") and break
// out of the inline <script> below: "<" occurs only inside JSON string values, and the
// WebView's JS engine decodes the escaped "<" back to a literal "<" when parsing the
// object literal, so the payload is preserved exactly. See ENG-1813.
const optionsJson = JSON.stringify(options).replaceAll(
"<",
String.raw`\u003c`,
);

return `
<!doctype html>
<html>
Expand Down Expand Up @@ -372,7 +381,7 @@ const renderHtml = (
function getSetIsError() { /* noop */ };

function loadSurvey() {
const options = ${JSON.stringify(options)};
const options = ${optionsJson};
const surveyProps = {
...options,
onDisplayCreated,
Expand Down
Loading