Skip to content

Apply inert client-script policy to base64 HTML artifacts #874

Description

@chubes4

Problem

Static_Site_Importer_Client_Script_Policy::apply() drops local JavaScript files from inert imports but filters script markup only through each HTML file's content field. Product and fixture-matrix artifacts encode every file through content_base64, so the policy writes an empty content value while leaving the original base64 HTML intact. Blocks Engine then receives HTML that still references the removed script asset and correctly rejects the site plan with unresolved_local_url.

Canonical fixture 10-nonprofit reproduces this with website/index.html -> js/main.js. Directly compiling the unchanged three-file artifact succeeds; applying SSI's default inert script policy first drops website/js/main.js while preserving the script declaration in website/index.html. This blocked the combined proof for Automattic/blocks-engine#688 and Automattic/blocks-engine#822.

Acceptance

  • Inert script filtering handles HTML represented by either content or content_base64.
  • Base64 HTML remains base64-represented after filtering and contains no executable script declarations.
  • Local script assets are removed without leaving unresolved local references.
  • Isolated-preview preservation remains byte-stable for base64 artifacts.
  • Policy reports hash the actual file bytes for both representations.
  • Contract coverage reproduces the product/matrix base64 artifact shape.

Reproduction

  1. Build a website artifact with base64-only website/index.html containing <script src="js/main.js"></script> and base64-only website/js/main.js.
  2. Call Static_Site_Importer_Client_Script_Policy::apply( $artifact, array() ).
  3. Observe that the JS file is removed but decoded content_base64 for the HTML still contains the script declaration.

AI assistance

OpenAI gpt-5.6-sol via OpenCode traced the canonical matrix failure through WP Codebox diagnostics, reproduced the artifact directly, and isolated the base64 policy mismatch. Chris Huber directed the investigation and remains responsible for the issue and resulting change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions