Skip to content

Commit 161573c

Browse files
authored
Use encodeURIComponent in browser_reporting. NFC (#23075)
While working on a separate change I ran into issues where chrome was refusing to fetch a report_result and this fixed the issue. It seems that the angle brackets in the backtrace after my PR were the issue: Before: ``` exception:fetch is not a function / TypeError: fetch is not a function at readAsync (https://b2607f8….proxy.googlers.com/a.out.js:284:12) at getBinaryPromise (https://b2607f8….proxy.googlers.com/a.out.js:774:12) at instantiateArrayBuffer (https://b2607f8….proxy.googlers.com/a.out.js:786:10) at instantiateAsync (https://b2607f8….proxy.googlers.com/a.out.js:832:10) at createWasm (https://b2607f8….proxy.googlers.com/a.out.js:909:3) at https://b2607f8….proxy.googlers.com/a.out.js:5310:19 ``` After: ``` exception:fetch is not a function / TypeError: fetch is not a function at readAsync (https://b2607f8….proxy.googlers.com/a.out.js:294:12) at getBinaryPromise (https://b2607f8….proxy.googlers.com/a.out.js:818:12) at https://b2607f8….proxy.googlers.com/a.out.js:831:5 at new Promise (<anonymous>) at instantiateArrayBuffer (https://b2607f8….proxy.googlers.com/a.out.js:830:10) at instantiateAsync (https://b2607f8….proxy.googlers.com/a.out.js:881:10) at createWasm (https://b2607f8….proxy.googlers.com/a.out.js:958:3) at https://b2607f8….proxy.googlers.com/a.out.js:5368:19 ```
1 parent cd4c6a4 commit 161573c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

test/browser_reporting.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function reportResultToServer(result, port) {
1414
out(`RESULT: ${result}`);
1515
} else {
1616
let doFetch = typeof origFetch != 'undefined' ? origFetch : fetch;
17-
doFetch(`http://localhost:${port}/report_result?${result}`).then(() => {
17+
doFetch(`http://localhost:${port}/report_result?${encodeURIComponent(result)}`).then(() => {
1818
if (typeof window === 'object' && window && hasModule && !Module['pageThrewException']) {
1919
/* for easy debugging, don't close window on failure */
2020
window.close();
@@ -24,7 +24,7 @@ function reportResultToServer(result, port) {
2424
}
2525

2626
function sendFileToServer(filename, contents) {
27-
fetch(`http://localhost:8888/?file=${filename}`, {method: "POST", body: contents});
27+
fetch(`http://localhost:8888/?file=${encodeURIComponent(filename)}`, {method: "POST", body: contents});
2828
}
2929

3030
/**
@@ -39,7 +39,7 @@ function reportErrorToServer(message) {
3939
if (typeof ENVIRONMENT_IS_NODE !== 'undefined' && ENVIRONMENT_IS_NODE) {
4040
err(message);
4141
} else {
42-
fetch(encodeURI(`http://localhost:8888?stderr=${message}`));
42+
fetch(`http://localhost:8888?stderr=${encodeURIComponent(message)}`);
4343
}
4444
}
4545

0 commit comments

Comments
 (0)