OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
do not fail pdf export on unpermitted image url
ulferts295cc22a67e5
diff --git a/app/models/work_package/pdf_export/common.rb b/app/models/work_package/pdf_export/common.rbindex 0529db5a499..893cf632255 100644--- a/app/models/work_package/pdf_export/common.rb+++ b/app/models/work_package/pdf_export/common.rb@@ -66,6 +66,19 @@ module WorkPackage::PdfExport::Common@cell_padding ||= [2, 5, 2, 5]end+ def configure_markup+ # Do not attempt to fetch images.+ # Fetching images can cause errors e.g. a 403 is returned when attempting to fetch from aws with+ # a no longer valid token.+ # Such an error would cause the whole export to error.+ pdf.markup_options = {+ image: {+ loader: ->(_src) { nil },+ placeholder: "<i>[#{I18n.t('export.image.omitted')}]</i>"+ }+ }+ end+### Writes the formatted work package description into the document.#diff --git a/app/models/work_package/pdf_export/work_package_list_to_pdf.rb b/app/models/work_package/pdf_export/work_package_list_to_pdf.rbindex 7d378f472d3..dcfbb103dfe 100644--- a/app/models/work_package/pdf_export/work_package_list_to_pdf.rb+++ b/app/models/work_package/pdf_export/work_package_list_to_pdf.rb@@ -42,6 +42,11 @@ class WorkPackage::PdfExport::WorkPackageListToPdf < WorkPackage::Exporter::Baseself.pdf = get_pdf(current_language)+ configure_page_size+ configure_markup+ end++ def configure_page_sizepdf.options[:page_size] = 'EXECUTIVE'pdf.options[:page_layout] = :landscapeend@@ -119,7 +124,7 @@ class WorkPackage::PdfExport::WorkPackageListToPdf < WorkPackage::Exporter::Basedef text_column?(column)column.is_a?(Queries::WorkPackages::Columns::CustomFieldColumn) &&- ['string', 'text'].include?(column.custom_field.field_format)+ %w(string text).include?(column.custom_field.field_format)enddef write_headers!diff --git a/app/models/work_package/pdf_export/work_package_to_pdf.rb b/app/models/work_package/pdf_export/work_package_to_pdf.rbindex d99dc35b4db..ce1f712e0e0 100644--- a/app/models/work_package/pdf_export/work_package_to_pdf.rb+++ b/app/models/work_package/pdf_export/work_package_to_pdf.rb@@ -38,6 +38,8 @@ class WorkPackage::PdfExport::WorkPackageToPdf < WorkPackage::Exporter::Basesuperself.pdf = get_pdf(current_language)++ configure_markupenddef render!diff --git a/config/locales/en.yml b/config/locales/en.ymlindex b87b01f1a23..3c8459a4dee 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -1141,6 +1141,8 @@ en:pdf_with_descriptions: "PDF with descriptions"pdf_with_descriptions_and_attachments: "PDF with descriptions and attachments"pdf_with_attachments: "PDF with attachments"+ image:+ omitted: "Image not exported."extraction:available:diff --git a/lib/open_project/text_formatting/matchers/link_handlers/colon_separator.rb b/lib/open_project/text_formatting/matchers/link_handlers/colon_separator.rbindex aac817d68cf..536c618d2e4 100644--- a/lib/open_project/text_formatting/matchers/link_handlers/colon_separator.rb+++ b/lib/open_project/text_formatting/matchers/link_handlers/colon_separator.rb@@ -107,12 +107,12 @@ module OpenProject::TextFormatting::Matchersanchor = $5link_to h("#{matcher.project_prefix}#{matcher.prefix}:#{oid}"),named_route(:entry_revision_project_repository,- action: 'entry',- project_id: project.identifier,- repo_path: path.to_s,- rev: rev,- anchor: anchor,- format: (matcher.prefix == 'export' ? 'raw' : nil)),+ action: 'entry',+ project_id: project.identifier,+ repo_path: path.to_s,+ rev: rev,+ anchor: anchor,+ format: (matcher.prefix == 'export' ? 'raw' : nil)),class: (matcher.prefix == 'export' ? 'source download' : 'source')endend