Skip to content

fix: update-sri.ts handle unquoted attributes after HTML minification#2434

Merged
pethers merged 1 commit into
mainfrom
copilot/fix-s3-deploy-issues-again
May 12, 2026
Merged

fix: update-sri.ts handle unquoted attributes after HTML minification#2434
pethers merged 1 commit into
mainfrom
copilot/fix-s3-deploy-issues-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 12, 2026

coderaiser/minify v15.x strips double quotes from HTML attributes, turning integrity="sha384-..." into integrity=sha384-.... The update-sri.ts regexes only matched quoted forms, so every HTML file was classified as "absent" and the script errored out during S3 deploy.

Changes

  • scripts/update-sri.ts — Made quotes optional ("?) in both linkTagRe and HASH_SNIFF_RE regexes to match both pre- and post-minification HTML
- `(<link\\b[^>]*\\bhref\\s*=\\s*"[^"]*${escapedName}[^"]*"[^>]*)` +
-   `(integrity\\s*=\\s*")sha384-[A-Za-z0-9+/=]+(")`,
+ `(<link\\b[^>]*\\bhref\\s*=\\s*"?[^"\\s>]*${escapedName}[^"\\s>]*"?[^>]*)` +
+   `(integrity\\s*=\\s*"?)sha384-[A-Za-z0-9+/=]+("?)`,
  • tests/css-purge-and-minify.test.ts — Added test case exercising unquoted attributes as produced by the minifier

The coderaiser/minify package strips quotes from HTML attributes,
turning integrity="sha384-..." into integrity=sha384-.... The
update-sri.ts regexes only matched quoted forms, causing the
"No HTML files reference X with an integrity attribute" error
in deploy-s3.yml.

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/98ba31d4-d346-4e76-9b20-cfc812698ef9

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
@pethers pethers marked this pull request as ready for review May 12, 2026 15:02
Copilot AI review requested due to automatic review settings May 12, 2026 15:02
@github-actions github-actions Bot added testing Test coverage refactor Code refactoring size-s Small change (10-50 lines) labels May 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🏷️ Automatic Labeling Summary

This PR has been automatically labeled based on the files changed and PR metadata.

Applied Labels: testing,refactor,size-s

Label Categories

  • 🗳️ Content: news, dashboard, visualization, intelligence
  • 💻 Technology: html-css, javascript, workflow, security
  • 📊 Data: cia-data, riksdag-data, data-pipeline, schema
  • 🌍 I18n: i18n, translation, rtl
  • 🔒 ISMS: isms, iso-27001, nist-csf, cis-controls
  • 🏗️ Infrastructure: ci-cd, deployment, performance, monitoring
  • 🔄 Quality: testing, accessibility, documentation, refactor
  • 🤖 AI: agent, skill, agentic-workflow

For more information, see .github/labeler.yml.

@github-actions
Copy link
Copy Markdown
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

@pethers pethers merged commit 93fe6c8 into main May 12, 2026
17 checks passed
@pethers pethers deleted the copilot/fix-s3-deploy-issues-again branch May 12, 2026 15:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the deploy-time SRI rewriter to correctly detect and update integrity=sha384-... attributes after HTML minification removes quotes, preventing false “absent integrity” failures during deploy.

Changes:

  • Updated update-sri.ts regexes to match both quoted and unquoted href / integrity attribute values.
  • Added a regression test covering unquoted attributes as produced by coderaiser/minify v15.x.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
scripts/update-sri.ts Makes SRI matching resilient to minified HTML by accepting unquoted href/integrity attribute values.
tests/css-purge-and-minify.test.ts Adds a fixture ensuring updateSri() updates integrity hashes when attributes are unquoted.

Comment thread scripts/update-sri.ts
Comment on lines +108 to +111
// Match href=["']?…<cssBasename>…["']? … integrity=["']?sha384-…["']?
// inside a <link> tag. The HTML minifier (coderaiser/minify) strips
// quotes from attributes whose values contain no special characters,
// so we must handle both quoted and unquoted forms.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Code refactoring size-s Small change (10-50 lines) testing Test coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants