Skip to content

Commit 931d7de

Browse files
authored
Revert "support subresource integrity for bootstrapScripts and bootstrapModules (#25104)"
This reverts commit 1e5245d.
1 parent 1e5245d commit 931d7de

File tree

6 files changed

+14
-101
lines changed

6 files changed

+14
-101
lines changed

packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -3390,61 +3390,6 @@ describe('ReactDOMFizzServer', () => {
33903390
});
33913391
});
33923392

3393-
it('accepts an integrity property for bootstrapScripts and bootstrapModules', async () => {
3394-
await actIntoEmptyDocument(() => {
3395-
const {pipe} = ReactDOMFizzServer.renderToPipeableStream(
3396-
<html>
3397-
<head />
3398-
<body>
3399-
<div>hello world</div>
3400-
</body>
3401-
</html>,
3402-
{
3403-
bootstrapScripts: [
3404-
'foo',
3405-
{
3406-
src: 'bar',
3407-
},
3408-
{
3409-
src: 'baz',
3410-
integrity: 'qux',
3411-
},
3412-
],
3413-
bootstrapModules: [
3414-
'quux',
3415-
{
3416-
src: 'corge',
3417-
},
3418-
{
3419-
src: 'grault',
3420-
integrity: 'garply',
3421-
},
3422-
],
3423-
},
3424-
);
3425-
pipe(writable);
3426-
});
3427-
3428-
expect(getVisibleChildren(document)).toEqual(
3429-
<html>
3430-
<head />
3431-
<body>
3432-
<div>hello world</div>
3433-
</body>
3434-
</html>,
3435-
);
3436-
expect(
3437-
Array.from(document.getElementsByTagName('script')).map(n => n.outerHTML),
3438-
).toEqual([
3439-
'<script src="foo" async=""></script>',
3440-
'<script src="bar" async=""></script>',
3441-
'<script src="baz" integrity="qux" async=""></script>',
3442-
'<script type="module" src="quux" async=""></script>',
3443-
'<script type="module" src="corge" async=""></script>',
3444-
'<script type="module" src="grault" integrity="garply" async=""></script>',
3445-
]);
3446-
});
3447-
34483393
describe('bootstrapScriptContent escaping', () => {
34493394
it('the "S" in "</?[Ss]cript" strings are replaced with unicode escaped lowercase s or S depending on case, preserving case sensitivity of nearby characters', async () => {
34503395
window.__test_outlet = '';

packages/react-dom/src/server/ReactDOMFizzServerBrowser.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99

1010
import type {ReactNodeList} from 'shared/ReactTypes';
11-
import type {BootstrapScriptDescriptor} from './ReactDOMServerFormatConfig';
1211

1312
import ReactVersion from 'shared/ReactVersion';
1413

@@ -29,8 +28,8 @@ type Options = {|
2928
namespaceURI?: string,
3029
nonce?: string,
3130
bootstrapScriptContent?: string,
32-
bootstrapScripts?: Array<string | BootstrapScriptDescriptor>,
33-
bootstrapModules?: Array<string | BootstrapScriptDescriptor>,
31+
bootstrapScripts?: Array<string>,
32+
bootstrapModules?: Array<string>,
3433
progressiveChunkSize?: number,
3534
signal?: AbortSignal,
3635
onError?: (error: mixed) => ?string,

packages/react-dom/src/server/ReactDOMFizzServerNode.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import type {ReactNodeList} from 'shared/ReactTypes';
1111
import type {Writable} from 'stream';
12-
import type {BootstrapScriptDescriptor} from './ReactDOMServerFormatConfig';
1312

1413
import ReactVersion from 'shared/ReactVersion';
1514

@@ -39,8 +38,8 @@ type Options = {|
3938
namespaceURI?: string,
4039
nonce?: string,
4140
bootstrapScriptContent?: string,
42-
bootstrapScripts?: Array<string | BootstrapScriptDescriptor>,
43-
bootstrapModules?: Array<string | BootstrapScriptDescriptor>,
41+
bootstrapScripts?: Array<string>,
42+
bootstrapModules?: Array<string>,
4443
progressiveChunkSize?: number,
4544
onShellReady?: () => void,
4645
onShellError?: (error: mixed) => void,

packages/react-dom/src/server/ReactDOMFizzStaticBrowser.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99

1010
import type {ReactNodeList} from 'shared/ReactTypes';
11-
import type {BootstrapScriptDescriptor} from './ReactDOMServerFormatConfig';
1211

1312
import ReactVersion from 'shared/ReactVersion';
1413

@@ -28,8 +27,8 @@ type Options = {|
2827
identifierPrefix?: string,
2928
namespaceURI?: string,
3029
bootstrapScriptContent?: string,
31-
bootstrapScripts?: Array<string | BootstrapScriptDescriptor>,
32-
bootstrapModules?: Array<string | BootstrapScriptDescriptor>,
30+
bootstrapScripts?: Array<string>,
31+
bootstrapModules?: Array<string>,
3332
progressiveChunkSize?: number,
3433
signal?: AbortSignal,
3534
onError?: (error: mixed) => ?string,

packages/react-dom/src/server/ReactDOMFizzStaticNode.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
*/
99

1010
import type {ReactNodeList} from 'shared/ReactTypes';
11-
import type {BootstrapScriptDescriptor} from './ReactDOMServerFormatConfig';
12-
1311
import {Writable, Readable} from 'stream';
1412

1513
import ReactVersion from 'shared/ReactVersion';
@@ -30,8 +28,8 @@ type Options = {|
3028
identifierPrefix?: string,
3129
namespaceURI?: string,
3230
bootstrapScriptContent?: string,
33-
bootstrapScripts?: Array<string | BootstrapScriptDescriptor>,
34-
bootstrapModules?: Array<string | BootstrapScriptDescriptor>,
31+
bootstrapScripts?: Array<string>,
32+
bootstrapModules?: Array<string>,
3533
progressiveChunkSize?: number,
3634
signal?: AbortSignal,
3735
onError?: (error: mixed) => ?string,

packages/react-dom/src/server/ReactDOMServerFormatConfig.js

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ const endInlineScript = stringToPrecomputedChunk('</script>');
8282

8383
const startScriptSrc = stringToPrecomputedChunk('<script src="');
8484
const startModuleSrc = stringToPrecomputedChunk('<script type="module" src="');
85-
const scriptIntegirty = stringToPrecomputedChunk('" integrity="');
8685
const endAsyncScript = stringToPrecomputedChunk('" async=""></script>');
8786

8887
/**
@@ -105,17 +104,13 @@ const scriptRegex = /(<\/|<)(s)(cript)/gi;
105104
const scriptReplacer = (match, prefix, s, suffix) =>
106105
`${prefix}${s === 's' ? '\\u0073' : '\\u0053'}${suffix}`;
107106

108-
export type BootstrapScriptDescriptor = {
109-
src: string,
110-
integrity?: string,
111-
};
112107
// Allows us to keep track of what we've already written so we can refer back to it.
113108
export function createResponseState(
114109
identifierPrefix: string | void,
115110
nonce: string | void,
116111
bootstrapScriptContent: string | void,
117-
bootstrapScripts: $ReadOnlyArray<string | BootstrapScriptDescriptor> | void,
118-
bootstrapModules: $ReadOnlyArray<string | BootstrapScriptDescriptor> | void,
112+
bootstrapScripts: Array<string> | void,
113+
bootstrapModules: Array<string> | void,
119114
): ResponseState {
120115
const idPrefix = identifierPrefix === undefined ? '' : identifierPrefix;
121116
const inlineScriptWithNonce =
@@ -134,42 +129,20 @@ export function createResponseState(
134129
}
135130
if (bootstrapScripts !== undefined) {
136131
for (let i = 0; i < bootstrapScripts.length; i++) {
137-
const scriptConfig = bootstrapScripts[i];
138-
const src =
139-
typeof scriptConfig === 'string' ? scriptConfig : scriptConfig.src;
140-
const integrity =
141-
typeof scriptConfig === 'string' ? undefined : scriptConfig.integrity;
142132
bootstrapChunks.push(
143133
startScriptSrc,
144-
stringToChunk(escapeTextForBrowser(src)),
134+
stringToChunk(escapeTextForBrowser(bootstrapScripts[i])),
135+
endAsyncScript,
145136
);
146-
if (integrity) {
147-
bootstrapChunks.push(
148-
scriptIntegirty,
149-
stringToChunk(escapeTextForBrowser(integrity)),
150-
);
151-
}
152-
bootstrapChunks.push(endAsyncScript);
153137
}
154138
}
155139
if (bootstrapModules !== undefined) {
156140
for (let i = 0; i < bootstrapModules.length; i++) {
157-
const scriptConfig = bootstrapModules[i];
158-
const src =
159-
typeof scriptConfig === 'string' ? scriptConfig : scriptConfig.src;
160-
const integrity =
161-
typeof scriptConfig === 'string' ? undefined : scriptConfig.integrity;
162141
bootstrapChunks.push(
163142
startModuleSrc,
164-
stringToChunk(escapeTextForBrowser(src)),
143+
stringToChunk(escapeTextForBrowser(bootstrapModules[i])),
144+
endAsyncScript,
165145
);
166-
if (integrity) {
167-
bootstrapChunks.push(
168-
scriptIntegirty,
169-
stringToChunk(escapeTextForBrowser(integrity)),
170-
);
171-
}
172-
bootstrapChunks.push(endAsyncScript);
173146
}
174147
}
175148
return {

0 commit comments

Comments
 (0)