From 14e4fd1ff2462e8989cb64418be742d7dcfe1549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Markb=C3=A5ge?= Date: Sat, 13 Mar 2021 09:54:59 -0500 Subject: [PATCH] [Fizz] Move DOM/Native format configs to their respective packages (#20994) * Move DOM/Native format configs to their respective packages The streaming configs (Node/Browser) are different because they operate at another dimension that exists in each package. * Use escapeTextForBrowser to encode dynamic strings We can now use local dependencies --- .../src/server}/ReactDOMServerFormatConfig.js | 7 +++---- .../src/server}/ReactNativeServerFormatConfig.js | 0 .../src/forks/ReactServerFormatConfig.dom-browser.js | 2 +- .../src/forks/ReactServerFormatConfig.dom-relay.js | 2 +- .../react-server/src/forks/ReactServerFormatConfig.dom.js | 2 +- .../src/forks/ReactServerFormatConfig.native-relay.js | 2 +- 6 files changed, 7 insertions(+), 8 deletions(-) rename packages/{react-server/src => react-dom/src/server}/ReactDOMServerFormatConfig.js (98%) rename packages/{react-server/src => react-native-renderer/src/server}/ReactNativeServerFormatConfig.js (100%) diff --git a/packages/react-server/src/ReactDOMServerFormatConfig.js b/packages/react-dom/src/server/ReactDOMServerFormatConfig.js similarity index 98% rename from packages/react-server/src/ReactDOMServerFormatConfig.js rename to packages/react-dom/src/server/ReactDOMServerFormatConfig.js index 104834ca88ecd..b06196c452a60 100644 --- a/packages/react-server/src/ReactDOMServerFormatConfig.js +++ b/packages/react-dom/src/server/ReactDOMServerFormatConfig.js @@ -14,6 +14,7 @@ import { convertStringToBuffer, } from 'react-server/src/ReactServerStreamConfig'; +import escapeTextForBrowser from './escapeTextForBrowser'; import invariant from 'shared/invariant'; // Per response, @@ -46,13 +47,11 @@ export function createSuspenseBoundaryID( } function encodeHTMLIDAttribute(value: string): string { - // TODO: This needs to be encoded for security purposes. - return value; + return escapeTextForBrowser(value); } function encodeHTMLTextNode(text: string): string { - // TOOD: This needs to be encoded for security purposes. - return text; + return escapeTextForBrowser(text); } export function pushTextInstance( diff --git a/packages/react-server/src/ReactNativeServerFormatConfig.js b/packages/react-native-renderer/src/server/ReactNativeServerFormatConfig.js similarity index 100% rename from packages/react-server/src/ReactNativeServerFormatConfig.js rename to packages/react-native-renderer/src/server/ReactNativeServerFormatConfig.js diff --git a/packages/react-server/src/forks/ReactServerFormatConfig.dom-browser.js b/packages/react-server/src/forks/ReactServerFormatConfig.dom-browser.js index e06662579e5a2..c6e482efeb60c 100644 --- a/packages/react-server/src/forks/ReactServerFormatConfig.dom-browser.js +++ b/packages/react-server/src/forks/ReactServerFormatConfig.dom-browser.js @@ -7,4 +7,4 @@ * @flow */ -export * from '../ReactDOMServerFormatConfig'; +export * from 'react-dom/src/server/ReactDOMServerFormatConfig'; diff --git a/packages/react-server/src/forks/ReactServerFormatConfig.dom-relay.js b/packages/react-server/src/forks/ReactServerFormatConfig.dom-relay.js index e06662579e5a2..c6e482efeb60c 100644 --- a/packages/react-server/src/forks/ReactServerFormatConfig.dom-relay.js +++ b/packages/react-server/src/forks/ReactServerFormatConfig.dom-relay.js @@ -7,4 +7,4 @@ * @flow */ -export * from '../ReactDOMServerFormatConfig'; +export * from 'react-dom/src/server/ReactDOMServerFormatConfig'; diff --git a/packages/react-server/src/forks/ReactServerFormatConfig.dom.js b/packages/react-server/src/forks/ReactServerFormatConfig.dom.js index e06662579e5a2..c6e482efeb60c 100644 --- a/packages/react-server/src/forks/ReactServerFormatConfig.dom.js +++ b/packages/react-server/src/forks/ReactServerFormatConfig.dom.js @@ -7,4 +7,4 @@ * @flow */ -export * from '../ReactDOMServerFormatConfig'; +export * from 'react-dom/src/server/ReactDOMServerFormatConfig'; diff --git a/packages/react-server/src/forks/ReactServerFormatConfig.native-relay.js b/packages/react-server/src/forks/ReactServerFormatConfig.native-relay.js index 2cfdaeeb37688..96c71b77141a2 100644 --- a/packages/react-server/src/forks/ReactServerFormatConfig.native-relay.js +++ b/packages/react-server/src/forks/ReactServerFormatConfig.native-relay.js @@ -7,4 +7,4 @@ * @flow */ -export * from '../ReactNativeServerFormatConfig'; +export * from 'react-native-renderer/src/server/ReactNativeServerFormatConfig';