Skip to content

Keep URL import working on hostile HTML - #168

Merged
Programcode merged 3 commits into
mainfrom
cursor/import-html-wont-crash-791b
Oct 22, 2026
Merged

Programcode merged 3 commits into
mainfrom
cursor/import-html-wont-crash-791b

Conversation

@Programcode

Copy link
Copy Markdown
Owner

Importing a page could fail in two ways that showed up as a toast. A numeric character like &#99999999; threw inside String.fromCodePoint and that exception text was shown to the student. A page with thousands of unclosed <meta or <nav tags could also stall the function on a slow regular expression (called out as security-edge-7 in the October review).

The HTML helpers now walk the document once. Bad code points become empty text instead of throwing. Unclosed tags are skipped instead of being re-scanned. The import deadline is no longer cleared before that parse.

No UI change. A page that used to crash now imports, or fails with the existing import error rather than a parser exception.

Verified locally (GitHub Actions is out of minutes, so this is not a CI pass):

  • deno test supabase/functions/import-source/ (23 passed), including the bad-entity case and the 8,000 unclosed meta / 4,000 unclosed nav cases finishing in under half a second

Not run: npm run verify or a live URL import in the browser.

Open in Web Open in Cursor 

A numeric character past Unicode's range crashed the import, and unclosed meta or nav tags made the old regular expressions retry until the request died. Parsing now walks the page once and skips characters it cannot decode.

Co-authored-by: Gáborjáni-Szabó Ádám <Programcode@users.noreply.github.com>
@vercel

vercel Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
debate-navigator Ready Ready Preview Oct 22, 2026 11:06am UTC
debatelab-staging Ready Ready Preview Oct 22, 2026 11:06am UTC

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Next included review available in 2 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 34fb585 and 7724c90.

📒 Files selected for processing: 3
  • supabase/functions/import-source/html-text.ts
  • supabase/functions/import-source/html-text_test.ts
  • supabase/functions/import-source/index.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Essentials by visiting https://app.coderabbit.ai/settings/billing.

Comment @coderabbitai help to get the list of available commands.

The forward scan re-ran indexOf for the far close tag at every nesting
level, and a stray < with no > rescanned the rest of the page for each
character, so a 1 MB page of unclosed tags took minutes. Searches now
remember their last hit, and tag stripping in the text pass cannot run
past the next <. Adds 1 MB regression tests for each hostile shape.
@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

Deployment failed for project debatelab-staging with the following error:

Resource is limited - try again in 24 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/adam-gaborjanis-projects?upgradeToPro=build-rate-limit

@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

Deployment failed for project debate-navigator with the following error:

Resource is limited - try again in 1 day (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/adam-gaborjanis-projects?upgradeToPro=build-rate-limit

@Programcode
Programcode marked this pull request as ready for review October 22, 2026 13:13
Copilot AI balanced review requested due to automatic review settings October 22, 2026 13:13
@Programcode
Programcode merged commit 1ad9329 into main Oct 22, 2026
3 of 14 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

3 participants