Improve Power BI embed validation (invalid domain, duplicate constants, broken regex)

Created on 14 April 2025, 22 days ago

Problem/Motivation

The module currently fails to accept valid Power BI embed URLs and contains duplicated, outdated domain validation logic.

  1. Valid embed URLs are rejected:

    URLs like https://app.powerbi.com/reportEmbed?... are rejected with the message:

    This does not appear to contain a valid Power BI embed. Double check against the code copied from the share or embed dialog in Power BI and try again.

    This happens because the regex validation only allows https://app.powerbi.us, which is outdated and not functional.

  2. Duplicate and outdated domain constants:

    Both MediaPowerBiConstraintValidator.php and MediaPowerBiEmbedFormatter.php define the same hardcoded constants with https://app.powerbi.us and https://app.powerbigov.us.

    • app.powerbi.us does not resolve and produces ERR_SSL_UNRECOGNIZED_NAME_ALERT in modern browsers.
    • Domain constants are repeated and not aligned with current Microsoft recommendations.
  3. Incorrect and duplicated regex logic:

    The getUrlRegexPattern() method exists in two places, and it only matches the domain, not the full embed URL. The iframe then renders incorrectly.

Official domains according to Microsoft documentation:

https://learn.microsoft.com/en-us/power-bi/enterprise/service-govus-overview

Steps to reproduce

  1. Create a new media item of type Power BI.
  2. Paste a valid embed URL such as https://app.powerbi.com/reportEmbed?reportId=...
  3. Save the media item.
  4. Observe validation error and incorrect iframe rendering.

Proposed resolution

  • Replace domain validation regex with a shared list of official Microsoft Power BI domains.
  • Use parse_url() + in_array() for cleaner, faster validation.
  • Remove duplicated constants and shared getUrlRegexPattern() method.
  • Accept and properly render full embed URLs (with path and query).

Remaining tasks

  • Refactor both MediaPowerBiConstraintValidator and MediaPowerBiEmbedFormatter.
  • Add helper for shared domain list.

User interface changes

None.

Introduced terminology

None.

API changes

None. No change to public interfaces.

Data model changes

None.

Release notes snippet

Improves Power BI embed support by replacing outdated domain validation and fragile regex logic with a reliable, standards-based approach.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024