diff --git a/ts/linkPreviews/linkPreviewFetch.ts b/ts/linkPreviews/linkPreviewFetch.ts
index 7d845e882c3..38ecdb49ec7 100644
--- a/ts/linkPreviews/linkPreviewFetch.ts
+++ b/ts/linkPreviews/linkPreviewFetch.ts
@@ -20,9 +20,9 @@ const MAX_CONTENT_TYPE_LENGTH_TO_PARSE = 100;
// Though we'll accept HTML of any Content-Length (including no specified length), we
// will only load some of the HTML. So we might start loading a 99 gigabyte HTML page
-// but only parse the first 100 kilobytes. However, if the Content-Length is less than
+// but only parse the first 500 kilobytes. However, if the Content-Length is less than
// this, we won't waste space.
-const MAX_HTML_BYTES_TO_LOAD = 100 * 1024;
+const MAX_HTML_BYTES_TO_LOAD = 500 * 1024;
// `
x` is 8 bytes. Nothing else (meta tags, etc) will even fit, so we can ignore
// it. This is mostly to protect us against empty response bodies.
@@ -280,10 +280,6 @@ const getHtmlDocument = async (
if (hasLoadedMaxBytes) {
break;
}
- const hasFinishedLoadingHead = result.body.innerHTML.length > 0;
- if (hasFinishedLoadingHead) {
- break;
- }
}
/* eslint-enable no-restricted-syntax */
} catch (err) {
diff --git a/ts/test-electron/linkPreviews/linkPreviewFetch_test.ts b/ts/test-electron/linkPreviews/linkPreviewFetch_test.ts
index cfe97ad2dad..f2c98535e64 100644
--- a/ts/test-electron/linkPreviews/linkPreviewFetch_test.ts
+++ b/ts/test-electron/linkPreviews/linkPreviewFetch_test.ts
@@ -720,33 +720,6 @@ describe('link preview fetching', () => {
);
});
- it('stops reading as soon as the starts', async () => {
- const shouldNeverBeCalled = sinon.stub();
-
- const fakeFetch = stub().resolves(
- makeResponse({
- body: (async function* body() {
- yield new TextEncoder().encode(
- 'foo barX'
- );
- shouldNeverBeCalled();
- })(),
- })
- );
-
- assert.propertyVal(
- await fetchLinkPreviewMetadata(
- fakeFetch,
- 'https://example.com',
- new AbortController().signal
- ),
- 'title',
- 'foo bar'
- );
-
- sinon.assert.notCalled(shouldNeverBeCalled);
- });
-
it('handles incomplete bodies', async () => {
const fakeFetch = stub().resolves(
makeResponse({
@@ -803,7 +776,7 @@ describe('link preview fetching', () => {
sinon.assert.notCalled(shouldNeverBeCalled);
});
- it('stops reading gigantic bodies after 100 kilobytes', async () => {
+ it('stops reading bodies after 500 kilobytes', async () => {
const shouldNeverBeCalled = sinon.stub();
const fakeFetch = stub().resolves(
@@ -813,7 +786,7 @@ describe('link preview fetching', () => {
'foo bar'
);
const spaces = new Uint8Array(1024).fill(32);
- for (let i = 0; i < 100; i += 1) {
+ for (let i = 0; i < 500; i += 1) {
yield spaces;
}
shouldNeverBeCalled();
diff --git a/ts/util/lint/exceptions.json b/ts/util/lint/exceptions.json
index f24c29c55bf..80b2ee76ff0 100644
--- a/ts/util/lint/exceptions.json
+++ b/ts/util/lint/exceptions.json
@@ -13148,24 +13148,6 @@
"updated": "2019-11-21T06:13:49.384Z",
"reasonDetail": "Used for setting focus only"
},
- {
- "rule": "DOM-innerHTML",
- "path": "ts/linkPreviews/linkPreviewFetch.js",
- "line": " const hasFinishedLoadingHead = result.body.innerHTML.length > 0;",
- "lineNumber": 212,
- "reasonCategory": "usageTrusted",
- "updated": "2020-09-09T21:20:16.643Z",
- "reasonDetail": "This only deals with a fake DOM used when parsing link preview HTML, and it doesn't even change innerHTML."
- },
- {
- "rule": "DOM-innerHTML",
- "path": "ts/linkPreviews/linkPreviewFetch.ts",
- "line": " const hasFinishedLoadingHead = result.body.innerHTML.length > 0;",
- "lineNumber": 283,
- "reasonCategory": "usageTrusted",
- "updated": "2020-09-09T21:20:16.643Z",
- "reasonDetail": "This only deals with a fake DOM used when parsing link preview HTML, and it doesn't even change innerHTML."
- },
{
"rule": "jQuery-wrap(",
"path": "ts/shims/textsecure.js",
@@ -13344,4 +13326,4 @@
"reasonCategory": "falseMatch",
"updated": "2020-09-08T23:07:22.682Z"
}
-]
+]
\ No newline at end of file