Skip to content

✨ [amp-brid-player] Allow the JSON config child in the validator - #40583

Open
danijel-ristic wants to merge 6 commits into
ampproject:mainfrom
danijel-ristic:brid-player-json-child-validator
Open

danijel-ristic wants to merge 6 commits into
ampproject:mainfrom
danijel-ristic:brid-player-json-child-validator

Conversation

@danijel-ristic

Copy link
Copy Markdown
Contributor

amp-brid-player and its alias amp-target-video-player have read a child <script type="application/json"> as player config since #38984, but the validator rules were never updated, so pages using it fail validation.

Add tag specs for script[type=application/json] under both tag names, valid test cases for each, and document the JSON config child.

@CLAassistant

CLAassistant commented Nov 27, 2026 •

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ danijel-ristic
❌ dnrstc
You have signed the CLA already but the status is still pending? Let us recheck it.

amp-brid-player and its alias amp-target-video-player have read a child
<script type="application/json"> as player config since ampproject#38984, but the
validator rules were never updated, so pages using it fail validation.

Add tag specs for script[type=application/json] under both tag names,
valid test cases for each, and document the JSON config child.
@danijel-ristic
danijel-ristic force-pushed the brid-player-json-child-validator branch from a3f0bbf to e7690f5 Compare November 27, 2026 07:52
brid.tv no longer resolves, which fails the check-links CI step for any
PR touching this doc. Point the intro link at target-video.com, refer to
the platform as TargetVideo, and mention the amp-target-video-player
alias.
GitHub answers automated requests for blob pages with 503, which fails
check-links even though the link is valid.
@erwinmombay

Copy link
Copy Markdown
Member

Blocking

  • Config is not URL-encoded. amp-brid-player.js:148 appends &cust_config= + JSON.stringify(...) to the iframe URL without encodeURIComponent. Until now, valid AMP pages couldn't reach this code, and this PR makes it reachable. A #, &, =, + or % in a config value cuts off the URL or adds extra query params. The iframe still loads from the same origin, so this is not XSS. Fix: encode the value and update the unit test expectation (test-amp-brid-player.js:205).

Minor

  • Multiple JSON children. The validator allows them, but the runtime only uses config when there is exactly one, and otherwise drops it without a warning. Add a doc note. A warning only makes sense when a <script> child is actually present, not on every player.
  • Validator tests cover only valid examples. Add invalid cases: wrong type, <!-- in the JSON, a JSON script nested inside a <div>, and a JSON script with src.
  • Link-check exemption. Replace the markdown-link-check-disable around the Validation link with a relative link (validator-amp-brid-player.protoascii). The checker then verifies it locally and GitHub's 503 doesn't matter. 34 other extension docs already do this.

Nits

  • Say in the docs that amp-target-video-player still needs the amp-brid-player extension script and takes the same attributes.
  • Link to TargetVideo's list of supported config keys.
  • The docs now say TargetVideo, but the code still uses the services.brid.tv / cdn.brid.tv hosts. Confirm this is intended.
  • Add a unit test for the alias tag with a JSON config. Consider a size limit on the script config, since it ends up in a URL.

The config was appended to the iframe src as raw JSON, so a #, &, =, +
or % in a value cut off the URL or added extra query params. Encode it
with encodeURIComponent.

When a <script> child is present but its config can't be used (more
than one child, wrong type or invalid JSON), log a warning instead of
dropping it silently. Players without a <script> child stay quiet.

Add tests for reserved characters, the amp-target-video-player alias
with a config, and the warning.
…hild

Cover a wrong type, an HTML comment in the JSON, a script nested inside
a div, and a script with a src attribute.
Say that amp-target-video-player takes the same attributes and still
needs the amp-brid-player extension script, that only a single
<script> config child is used, and link to TargetVideo's embed
options. Replace the link-check exemption with a relative link to the
validator rules, which check-links verifies locally.
@danijel-ristic
danijel-ristic force-pushed the brid-player-json-child-validator branch from 80980af to 83e6aa4 Compare December 2, 2026 10:04
@danijel-ristic

Copy link
Copy Markdown
Contributor Author

Hi @erwinmombay, any updates on this?

This branch has not been deployed

No deployments
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