From c3af1a9ad6de883e9fcadfce6c0bd73e4decbcf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 4 Aug 2026 10:38:45 +0200 Subject: [PATCH] Restrict protocols allowed for weasyprint to http(s) Closes #14947 (grafted from 7c72806c98c07bb4ccb1f5f1b84954350541ec3a) --HG-- branch : 8.0 --- trytond/CHANGELOG | 1 + trytond/pyproject.toml | 2 +- trytond/trytond/report/report.py | 7 ++++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/trytond/CHANGELOG b/trytond/CHANGELOG index 305c3ec7a3..810a7226aa 100644 --- a/trytond/CHANGELOG +++ b/trytond/CHANGELOG @@ -1,3 +1,4 @@ +* Restrict protocols allowed for weasyprint to http(s) (issue14947) Version 8.0.7 - 2026-07-15 -------------------------- diff --git a/trytond/pyproject.toml b/trytond/pyproject.toml index 49aa365697..a324595753 100644 --- a/trytond/pyproject.toml +++ b/trytond/pyproject.toml @@ -60,7 +60,7 @@ test = [ 'pillow', 'pydot', ] -weasyprint = ['weasyprint'] +weasyprint = ['weasyprint >= 68.0'] [project.scripts] trytond = 'trytond.cli:main' diff --git a/trytond/trytond/report/report.py b/trytond/trytond/report/report.py index cf6519b3d3..62390b6ed4 100644 --- a/trytond/trytond/report/report.py +++ b/trytond/trytond/report/report.py @@ -414,7 +414,12 @@ class Report(URLMixin, PoolBase): if (input_format in {'html', 'xhtml'} and output_format == 'pdf'): if weasyprint := _lazy_import('weasyprint'): - return output_format, weasyprint.HTML(string=data).write_pdf() + return output_format, weasyprint.HTML( + string=data, + url_fetcher=weasyprint.URLFetcher( + allowed_protocols={'http', 'https'}, + ), + ).write_pdf() if (input_format == 'xml' and output_format == 'html'