Skip to content

Add test for HTML escaping in generated scraper code#105

Merged
mbuckingham74 merged 1 commit intomainfrom
test/html-escape-generated-scraper
Dec 2, 2025
Merged

Add test for HTML escaping in generated scraper code#105
mbuckingham74 merged 1 commit intomainfrom
test/html-escape-generated-scraper

Conversation

@mbuckingham74
Copy link
Owner

Summary

Test plan

  • CI passes
  • Test would fail if the |e filter is removed from generated_scraper.html

🤖 Generated with Claude Code

Ensures that AI-generated Python code containing HTML-like sequences
(</script>, </code>, </pre>) is properly escaped when rendered in
the admin partial. This prevents XSS and JavaScript parsing errors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


# Raw HTML-breaking sequences should NOT appear
assert "</script><script>" not in response.text
assert "</code></pre>" not in response.text

Choose a reason for hiding this comment

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

P1 Badge Test forbids template closing tags that are always present

The new assertion assert "</code></pre>" not in response.text will fail even when the scraper code is properly escaped because the generated_scraper.html template always emits its own </code></pre> closing tags around the code block (see backend/app/templates/admin/partials/generated_scraper.html:66). That means this test will always fail regardless of the fix it intends to protect, preventing the suite from passing and not actually detecting regressions in escaping. The check should look for escaped sequences or additional occurrences instead of forbidding the template’s markup.

Useful? React with 👍 / 👎.

@mbuckingham74 mbuckingham74 merged commit 3a0a341 into main Dec 2, 2025
1 check failed
@mbuckingham74 mbuckingham74 deleted the test/html-escape-generated-scraper branch December 2, 2025 12:26
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