-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a maximum feed size #906
base: main
Are you sure you want to change the base?
Conversation
tests/FeedReader.spec.ts
Outdated
const items = await storage.hasSeenFeedGuids(feedUrl, ...expectedHash); | ||
expect(items).to.deep.equal(expectedHash); | ||
}); | ||
it.only("should fail to handle a feed which exceed the maximum size.", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Focused test!
We could probably use the "no focused tests" eslint rule.
tests/FeedReader.spec.ts
Outdated
it.only("should fail to handle a feed which exceed the maximum size.", async () => { | ||
const { feedReader, feedUrl } = await constructFeedReader(() => ({ | ||
headers: { | ||
'Content-Length': Math.pow(1024, 2).toString(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, isn't this exactly 1 megabyte? This should not be failing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nitpicks, but good to go.
}, | ||
Ok(body) => { | ||
// Check if we only got the length after loading the response. | ||
match body.len() as u64 <= max_content_size { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: I'd just write it as if body.len() as u64 <= max_content_size {
..., since if
is also an expression in Rust. match
kinda makes it seems like there's more to it than that.
<guid isPermaLink="true">http://www.example.com/blog/post/${i}</guid> | ||
</item>`).join('')} | ||
</channel> | ||
</rss>`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this is fine, measuring at 1.2 MB. If we wanted to be extra careful, we could do an assert checking if it's longer than 1024*1024.
This prevents massive feeds from potentially clogging up Hookshot. Some RSS/ATOM feeds are horribly maintained and just list every entry ever, so we've set a "sensible limit" of 25MB.