From d576b8ed47d4623920302f8840592ce7be4c43b1 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 8 Feb 2024 15:01:20 -0600 Subject: [PATCH] Switch to isomorphic-dompurify --- package.json | 2 +- .../components/site-banner.tsx | 2 +- src/normalizers/status-edit.ts | 2 +- src/reducers/statuses.ts | 2 +- src/schemas/account.ts | 2 +- src/schemas/poll.ts | 2 +- yarn.lock | 48 +++++++++++++++++++ 7 files changed, 54 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index c71e853dc..3a6a1b2a6 100644 --- a/package.json +++ b/package.json @@ -112,7 +112,6 @@ "cryptocurrency-icons": "^0.18.1", "cssnano": "^6.0.0", "detect-passive-events": "^2.0.0", - "dompurify": "^3.0.8", "dotenv": "^16.0.0", "emoji-datasource": "14.0.0", "emoji-mart": "^5.5.2", @@ -126,6 +125,7 @@ "intersection-observer": "^0.12.2", "intl-messageformat": "10.5.8", "intl-pluralrules": "^2.0.0", + "isomorphic-dompurify": "^2.3.0", "leaflet": "^1.8.0", "lexical": "^0.12.4", "line-awesome": "^1.3.0", diff --git a/src/features/landing-timeline/components/site-banner.tsx b/src/features/landing-timeline/components/site-banner.tsx index 44776a43f..ffbdafe35 100644 --- a/src/features/landing-timeline/components/site-banner.tsx +++ b/src/features/landing-timeline/components/site-banner.tsx @@ -1,4 +1,4 @@ -import * as DOMPurify from 'dompurify'; +import DOMPurify from 'isomorphic-dompurify'; import React from 'react'; import Markup from 'soapbox/components/markup'; diff --git a/src/normalizers/status-edit.ts b/src/normalizers/status-edit.ts index 40e5acd35..a72e473ac 100644 --- a/src/normalizers/status-edit.ts +++ b/src/normalizers/status-edit.ts @@ -1,7 +1,6 @@ /** * Status edit normalizer */ -import * as DOMPurify from 'dompurify'; import escapeTextContentForBrowser from 'escape-html'; import { Map as ImmutableMap, @@ -9,6 +8,7 @@ import { Record as ImmutableRecord, fromJS, } from 'immutable'; +import DOMPurify from 'isomorphic-dompurify'; import emojify from 'soapbox/features/emoji'; import { normalizeAttachment } from 'soapbox/normalizers/attachment'; diff --git a/src/reducers/statuses.ts b/src/reducers/statuses.ts index 9083e4e66..b857ba540 100644 --- a/src/reducers/statuses.ts +++ b/src/reducers/statuses.ts @@ -1,6 +1,6 @@ -import * as DOMPurify from 'dompurify'; import escapeTextContentForBrowser from 'escape-html'; import { Map as ImmutableMap, List as ImmutableList } from 'immutable'; +import DOMPurify from 'isomorphic-dompurify'; import emojify from 'soapbox/features/emoji'; import { normalizeStatus } from 'soapbox/normalizers'; diff --git a/src/schemas/account.ts b/src/schemas/account.ts index 014820d34..b419b13cf 100644 --- a/src/schemas/account.ts +++ b/src/schemas/account.ts @@ -1,5 +1,5 @@ -import * as DOMPurify from 'dompurify'; import escapeTextContentForBrowser from 'escape-html'; +import DOMPurify from 'isomorphic-dompurify'; import z from 'zod'; import emojify from 'soapbox/features/emoji'; diff --git a/src/schemas/poll.ts b/src/schemas/poll.ts index a3012b178..1a60af410 100644 --- a/src/schemas/poll.ts +++ b/src/schemas/poll.ts @@ -1,5 +1,5 @@ -import * as DOMPurify from 'dompurify'; import escapeTextContentForBrowser from 'escape-html'; +import DOMPurify from 'isomorphic-dompurify'; import { z } from 'zod'; import emojify from 'soapbox/features/emoji'; diff --git a/yarn.lock b/yarn.lock index 7906e8f98..1235e8045 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3897,6 +3897,13 @@ cssstyle@^3.0.0: dependencies: rrweb-cssom "^0.6.0" +cssstyle@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/cssstyle/-/cssstyle-4.0.1.tgz#ef29c598a1e90125c870525490ea4f354db0660a" + integrity sha512-8ZYiJ3A/3OkDd093CBT/0UKDWry7ak4BdPTFP2+QEP7cmhouyq/Up709ASSj2cK02BbZiMgk7kYjZNS4QP5qrQ== + dependencies: + rrweb-cssom "^0.6.0" + csstype@^3.0.2: version "3.0.9" resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.0.9.tgz#6410af31b26bd0520933d02cbc64fce9ce3fbf0b" @@ -5716,6 +5723,15 @@ isexe@^2.0.0: resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= +isomorphic-dompurify@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/isomorphic-dompurify/-/isomorphic-dompurify-2.3.0.tgz#bc48fbdf52f84cf7e0a63a5e8ec89052e7dbc3c5" + integrity sha512-FCoKY4/mW/jnn/+VgE7wXGC2D/RXzVCAmGYuGWEuZXtyWnwmE2100caciIv+RbHk90q9LA0OW5IBn2f+ywHtww== + dependencies: + "@types/dompurify" "^3.0.5" + dompurify "^3.0.8" + jsdom "^24.0.0" + iterator.prototype@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/iterator.prototype/-/iterator.prototype-1.1.2.tgz#5e29c8924f01916cb9335f1ff80619dcff22b0c0" @@ -5809,6 +5825,33 @@ jsdom@^23.0.0: ws "^8.14.2" xml-name-validator "^5.0.0" +jsdom@^24.0.0: + version "24.0.0" + resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-24.0.0.tgz#e2dc04e4c79da368481659818ee2b0cd7c39007c" + integrity sha512-UDS2NayCvmXSXVP6mpTj+73JnNQadZlr9N68189xib2tx5Mls7swlTNao26IoHv46BZJFvXygyRtyXd1feAk1A== + dependencies: + cssstyle "^4.0.1" + data-urls "^5.0.0" + decimal.js "^10.4.3" + form-data "^4.0.0" + html-encoding-sniffer "^4.0.0" + http-proxy-agent "^7.0.0" + https-proxy-agent "^7.0.2" + is-potential-custom-element-name "^1.0.1" + nwsapi "^2.2.7" + parse5 "^7.1.2" + rrweb-cssom "^0.6.0" + saxes "^6.0.0" + symbol-tree "^3.2.4" + tough-cookie "^4.1.3" + w3c-xmlserializer "^5.0.0" + webidl-conversions "^7.0.0" + whatwg-encoding "^3.1.1" + whatwg-mimetype "^4.0.0" + whatwg-url "^14.0.0" + ws "^8.16.0" + xml-name-validator "^5.0.0" + jsesc@^2.5.1: version "2.5.2" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4" @@ -9500,6 +9543,11 @@ ws@^8.14.2: resolved "https://registry.yarnpkg.com/ws/-/ws-8.14.2.tgz#6c249a806eb2db7a20d26d51e7709eab7b2e6c7f" integrity sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g== +ws@^8.16.0: + version "8.16.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.16.0.tgz#d1cd774f36fbc07165066a60e40323eab6446fd4" + integrity sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ== + xcase@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/xcase/-/xcase-2.0.1.tgz#c7fa72caa0f440db78fd5673432038ac984450b9"