Skip to content

fix: preserve styling and images in URL-ingested citation pages - #2398

Merged
Roopan-Microsoft merged 2 commits into
Azure-Samples:devfrom
PadhiAjit-Microsoft:citation-url-fix
Oct 8, 2026
Merged

Roopan-Microsoft merged 2 commits into
Azure-Samples:devfrom
PadhiAjit-Microsoft:citation-url-fix

Conversation

@PadhiAjit-Microsoft

Copy link
Copy Markdown
Contributor

Purpose

  • This pull request enhances the ingestion pipeline to improve how HTML pages are stored and rendered for citation. The main change ensures that when an HTML page is ingested, it is modified to preserve its appearance and prevent scripts from running when viewed from a blob URL. Several robust tests have also been added to verify this behavior.

HTML snapshot preparation and security:

  • Added the _prepare_html_snapshot function to inject a <base href> (for resolving relative URLs) and a strict Content Security Policy <meta> (to prevent script execution) into HTML pages before storage. This ensures that when the stored HTML is viewed, it renders with correct styling and images but cannot execute scripts.
  • Modified ingest_url to apply _prepare_html_snapshot to HTML content only, leaving other file types (e.g., PDFs) unchanged. [1] [2]

Testing improvements:

  • Added comprehensive tests for _prepare_html_snapshot, covering correct injection after <head> or <html>, proper escaping of the source URL, and ensuring non-HTML files are unmodified.
  • Updated ingestion tests to check that HTML content is processed with _prepare_html_snapshot before upload, and non-HTML content remains untouched.

Imports and refactoring:

  • Added necessary imports for html and ParserKey to support the new logic. [1] [2]

Does this introduce a breaking change?

  • Yes
  • No

How to Test

  • Get the code
git clone [repo-address]
cd [repo-name]
git checkout [branch-name]
npm install
  • Test the code

What to Check

Verify that the following are valid

  • ...

Other Information

@Roopan-Microsoft
Roopan-Microsoft merged commit caac37b into Azure-Samples:dev Oct 8, 2026
9 of 10 checks passed
@PadhiAjit-Microsoft
PadhiAjit-Microsoft deleted the citation-url-fix branch October 8, 2026 12:09

This branch had an error being deployed

1 failed deployment
production — 222a4a79 Deployed Oct 8, 2026 by PadhiAjit-Microsoft via azd template validation #113
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.

2 participants