linkPreviewFetch: Increase maximum HTML we'll process to 1000*1024 bytes
This commit is contained in:
parent
fe98f90d70
commit
da9df293c6
2 changed files with 6 additions and 3 deletions
|
@ -27,9 +27,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 500 kilobytes. However, if the Content-Length is less than
|
||||
// but only parse the first 1000 kilobytes. However, if the Content-Length is less than
|
||||
// this, we won't waste space.
|
||||
const MAX_HTML_BYTES_TO_LOAD = 500 * 1024;
|
||||
const MAX_HTML_BYTES_TO_LOAD = 1000 * 1024;
|
||||
|
||||
// `<title>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.
|
||||
|
|
|
@ -843,7 +843,7 @@ describe('link preview fetching', () => {
|
|||
sinon.assert.notCalled(shouldNeverBeCalled);
|
||||
});
|
||||
|
||||
it('stops reading bodies after 500 kilobytes', async function test() {
|
||||
it('stops reading bodies after 1000 kilobytes', async function test() {
|
||||
const shouldNeverBeCalled = sinon.stub();
|
||||
|
||||
const fakeFetch = stub().resolves(
|
||||
|
@ -855,6 +855,9 @@ describe('link preview fetching', () => {
|
|||
const spaces = new Uint8Array(250 * 1024).fill(32);
|
||||
yield spaces;
|
||||
yield spaces;
|
||||
yield spaces;
|
||||
yield spaces;
|
||||
yield spaces;
|
||||
shouldNeverBeCalled();
|
||||
yield new TextEncoder().encode(
|
||||
'<meta property="og:description" content="should be ignored">'
|
||||
|
|
Loading…
Add table
Reference in a new issue