Description
📜 Description
The current implementation of the isSafe function assumes all src attributes in iframe elements contain absolute URLs because the full hostname is needed to compare against the allowed iframes configuration array.
Regex is not supported, wildcards are not supported, and we're stuck with having to be a full absolute path.
However, when an iframe has a relative path (e.g., ./something.html), the URL constructor throws an error, leading the function to return false, marking the iframe as unsafe regardless of its validity within the host environment.
Note: The Techdocs specific iframe allowed sources was not intuitive. Expectation was CSP framesources would be the "safety" check needed or the default allowed list. That'd require wildcard expression support for the allowed frame sources, which I can add as a new feature request if this morphs into something larger.
This creates issues when working in environments where relative paths are valid or required.
👍 Expected behavior
Links, images, and other elements that link to internal or external content have paths re-written in the addBaseUrl
function a few directory above in the html
folder.
Expectation is to be able to support a structure such as:
simple-docs/
├── catalog-info.yaml
├── mkdocs.yml
└── docs/
├── index.md
└── emails/
└── examples/
└── html_template.html
Using the npx @techdocs/cli generate
and npx @techdocs/cli serve
show the Docker container has the html_template.html in the correct folder location.
Not supporting relative iFrame source paths blocks being able to render required assets in Backstage techdocs.
👎 Actual Behavior with Screenshots
Functionally working in mkdocs and iframe works with relative paths.
👟 Reproduction steps
📃 Provide the context for the Bug.
We have some services that publish HTML templates of the content they offer or create for review by the developers to ensure it meets their requirements. Specifically with HTML email templates.
Being able to embed relative path content to the HTML templates is needed but not currently supported by Backstage due to issue outlined above.
🖥️ Your Environment
No response
👀 Have you spent some time to check if this bug has been raised before?
- I checked and didn't find similar issue
🏢 Have you read the Code of Conduct?
- I have read the Code of Conduct
Are you willing to submit PR?
Yes I am willing to submit a PR!