Skip to content

Extract the article from html the client sends - #122

Merged
paskal merged 1 commit into
masterfrom
feat/extract-html
Dec 5, 2026
Merged

paskal merged 1 commit into
masterfrom
feat/extract-html

Conversation

@paskal

@paskal paskal commented Dec 5, 2026

Copy link
Copy Markdown
Member

Previously, readability could extract only the pages it fetched itself, as an anonymous visitor. A page behind a login or a paywall, such as a paid newsletter post, came back as its sign-in page or teaser.

After this change, POST /api/extract-html takes {"url": ..., "html": ...} and extracts the article from the supplied html with the rule for the URL's domain, without fetching the page. A Reddit post page goes through the same Reddit converter as a fetched one, so it keeps its comments. The html is taken as UTF-8. UReadability.ExtractHTML does the extraction and refuses a URL that is not an absolute http or https URL with a host. A page larger than 16 MiB is refused with 413. The request logger keeps logging request bodies on the other routes but not on this one, since the page may be one only its reader can see. Pictures are still downloaded from their URLs to choose the lead image.

The route is meant for ukeeper-worker, which can then extract the page a reader's browser shows, including pages behind a login.

TestExtractHTML and TestServer_ExtractHTML cover the extraction against the same page fetched, the domain rule, a Reddit post page, URL validation, the size limit and the logging; each check fails when its part of the change is reverted. go test -race ./... and golangci-lint run pass.

A page behind a login or a paywall can't be extracted: readability
fetches it as an anonymous visitor and gets the sign-in page or a
teaser. A client that already has the page, such as the reader's
browser, can now send it.

POST /api/extract-html takes the URL and the html and extracts the
article from that html with the rule for the URL's domain, without
fetching the page. A page larger than 16 MiB is refused, and the
request body is kept out of the request log, since the page may be
one only its reader can see.
@paskal
paskal merged commit 073867a into master Dec 5, 2026
2 checks passed
@paskal
paskal deleted the feat/extract-html branch December 5, 2026 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant