-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch fmt and folly files with CodeQL fixes (#13281)
* add missing folly fix * fork fmt/core.h * Change files
- Loading branch information
1 parent
1304e2f
commit b06795e
Showing
10 changed files
with
3,265 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
change/@office-iss-react-native-win32-c19d617e-ea40-47f8-8b84-e955cb6aa24c.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "none", | ||
"comment": "CodeQL patch", | ||
"packageName": "@office-iss/react-native-win32", | ||
"email": "[email protected]", | ||
"dependentChangeType": "none" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/react-native-windows-c0a19313-151e-4923-99a9-6de723d37dbe.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "prerelease", | ||
"comment": "Folly and Fmt CodeQL patches", | ||
"packageName": "react-native-windows", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
153 changes: 153 additions & 0 deletions
153
...fice-iss/react-native-win32/src-win/Libraries/Core/Devtools/loadBundleFromServer.win32.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict-local | ||
* @format | ||
* @oncall react_native | ||
*/ | ||
|
||
import Networking from '../../Network/RCTNetworking'; | ||
import DevLoadingView from '../../Utilities/DevLoadingView'; | ||
import HMRClient from '../../Utilities/HMRClient'; | ||
import getDevServer from './getDevServer'; | ||
|
||
declare var global: {globalEvalWithSourceUrl?: (string, string) => mixed, ...}; | ||
|
||
let pendingRequests = 0; | ||
|
||
const cachedPromisesByUrl = new Map<string, Promise<void>>(); | ||
|
||
function asyncRequest( | ||
url: string, | ||
): Promise<{body: string, headers: {[string]: string}}> { | ||
let id = null; | ||
let responseText = null; | ||
let headers = null; | ||
let dataListener; | ||
let completeListener; | ||
let responseListener; | ||
let incrementalDataListener; | ||
return new Promise<{body: string, headers: {[string]: string}}>( | ||
(resolve, reject) => { | ||
dataListener = Networking.addListener( | ||
'didReceiveNetworkData', | ||
([requestId, response]) => { | ||
if (requestId === id) { | ||
responseText = response; | ||
} | ||
}, | ||
); | ||
incrementalDataListener = Networking.addListener( | ||
'didReceiveNetworkIncrementalData', | ||
([requestId, data]) => { | ||
if (requestId === id) { | ||
if (responseText != null) { | ||
responseText += data; | ||
} else { | ||
responseText = data; | ||
} | ||
} | ||
}, | ||
); | ||
responseListener = Networking.addListener( | ||
'didReceiveNetworkResponse', | ||
([requestId, status, responseHeaders]) => { | ||
if (requestId === id) { | ||
headers = responseHeaders; | ||
} | ||
}, | ||
); | ||
completeListener = Networking.addListener( | ||
'didCompleteNetworkResponse', | ||
([requestId, error]) => { | ||
if (requestId === id) { | ||
if (error) { | ||
reject(error); | ||
} else { | ||
//$FlowFixMe[incompatible-call] | ||
resolve({body: responseText, headers}); | ||
} | ||
} | ||
}, | ||
); | ||
Networking.sendRequest( | ||
'GET', | ||
'asyncRequest', | ||
url, | ||
{}, | ||
'', | ||
'text', | ||
true, | ||
0, | ||
requestId => { | ||
id = requestId; | ||
}, | ||
true, | ||
); | ||
}, | ||
).finally(() => { | ||
dataListener?.remove(); | ||
completeListener?.remove(); | ||
responseListener?.remove(); | ||
incrementalDataListener?.remove(); | ||
}); | ||
} | ||
|
||
function buildUrlForBundle(bundlePathAndQuery: string) { | ||
const {url: serverUrl} = getDevServer(); | ||
return ( | ||
serverUrl.replace(/\/+$/, '') + '/' + bundlePathAndQuery.replace(/^\/+/, '') | ||
); | ||
} | ||
|
||
module.exports = function (bundlePathAndQuery: string): Promise<void> { | ||
const requestUrl = buildUrlForBundle(bundlePathAndQuery); | ||
let loadPromise = cachedPromisesByUrl.get(requestUrl); | ||
|
||
if (loadPromise) { | ||
return loadPromise; | ||
} | ||
DevLoadingView.showMessage('Downloading...', 'load'); | ||
++pendingRequests; | ||
|
||
loadPromise = asyncRequest(requestUrl) | ||
.then<void>(({body, headers}) => { | ||
if ( | ||
headers['Content-Type'] != null && | ||
headers['Content-Type'].indexOf('application/json') >= 0 | ||
) { | ||
// Errors are returned as JSON. | ||
throw new Error( | ||
JSON.parse(body).message || | ||
`Unknown error fetching '${bundlePathAndQuery}'`, | ||
); | ||
} | ||
|
||
HMRClient.registerBundle(requestUrl); | ||
|
||
// Some engines do not support `sourceURL` as a comment. We expose a | ||
// `globalEvalWithSourceUrl` function to handle updates in that case. | ||
if (global.globalEvalWithSourceUrl) { | ||
global.globalEvalWithSourceUrl(body, requestUrl); | ||
} else { | ||
// [Windows #12704 - CodeQL patch] | ||
// eslint-disable-next-line no-eval | ||
eval(body); // CodeQL [js/eval-usage] Debug only. Developer inner loop. | ||
} | ||
}) | ||
.catch<void>(e => { | ||
cachedPromisesByUrl.delete(requestUrl); | ||
throw e; | ||
}) | ||
.finally(() => { | ||
if (!--pendingRequests) { | ||
DevLoadingView.hide(); | ||
} | ||
}); | ||
|
||
cachedPromisesByUrl.set(requestUrl, loadPromise); | ||
return loadPromise; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.