Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] Feature - Allow fetching external urls matching a regex pattern #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kohlerdominik
Copy link

@kohlerdominik kohlerdominik commented Jan 25, 2024

Hello there

We are currently using a similar container, but it's abandoned. Therefore, we are looking for a new solutions, and yours looks great. Unfortunately, there is currently this limitation in place, which makes it unusable for us, therefore we are suggesting a new feature.


Description

This PR adds a new feature, allowing to fetch external urls. As I understand, that the restriction on external urls is in place as security measure, which is very reasonable. Therefore, the default of this feature would be to still suppress all requests to external urls.

But it adds the possibility to configure one or more patterns for external, urls that are allowed. Example of the configuration

services:
  weasyprint:
    image: 4teamwork/weasyprint:latest
    environment:
      ALLOWED_URL_PATTERN: '^https://fonts\.example\.com.*|^https://logos\.example\.com.*'
    ports:
      - 3000:8080

With this example, it would be possible to fetch fonts and logos from the storage of our site example.com. Of course, a regex pattern makes this very flexible.


Our use-case

Our customers are able to create their own templates in our web-editor. This renders HTML-previews in real-time in the browser, so there is no need to constantly refresh the PDF-preview. Because this all runs in the browser, we store the available fonts on our CDN-server, which the browser can fetch directly. It's much simpler to provide font files or shared pictures in a CDN than to fetch them all in the application and pass them as asset in the form.


This is a draft. I think, the implementation is fine like this (excepct if you request changes). I'm willing to add example and documentation.

I'm currently not sure, if there are automated tests in place? I'm happy to add them for our feature as well, if you can point me in the right direction.

@kohlerdominik
Copy link
Author

Ping @buchi

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.

None yet

1 participant