Skip to content

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

feat(pdf-export): stop double escaping of html entities

as-op5288c6d3e750
diff --git a/app/models/work_package/pdf_export/common.rb b/app/models/work_package/pdf_export/common.rb
index 9c42bc698f1..abf9cd9dd0a 100644
--- a/app/models/work_package/pdf_export/common.rb
+++ b/app/models/work_package/pdf_export/common.rb
@@ -114,13 +114,18 @@ module WorkPackage::PDFExport::Common
end
def get_column_value_cell(work_package, column)
- value = ERB::Util.html_escape(get_column_value(work_package, column))
+ value = escape_tags(get_column_value(work_package, column))
return get_id_column_cell(work_package, value) if column == :id
return get_subject_column_cell(work_package, value) if with_descriptions? && column == :subject
value
end
+ def escape_tags(value)
+ # only disable html tags, but do not replace html entities
+ value.gsub('<', '&lt;').gsub('>', '&gt;')
+ end
+
def get_id_column_cell(work_package, value)
href = url_helpers.work_package_url(work_package)
make_link_href_cell(href, value)
diff --git a/app/models/work_package/pdf_export/work_package_detail.rb b/app/models/work_package/pdf_export/work_package_detail.rb
index 5ad44f5d719..1e346adb475 100644
--- a/app/models/work_package/pdf_export/work_package_detail.rb
+++ b/app/models/work_package/pdf_export/work_package_detail.rb
@@ -60,14 +60,14 @@ module WorkPackage::PDFExport::WorkPackageDetail
with_margin(attributes_table_margins_style) do
pdf.table(
rows, column_widths: attributes_table_column_widths,
- cell_style: attributes_table_cell_style.merge({ inline_format: true })
+ cell_style: attributes_table_cell_style.merge({ inline_format: true })
)
end
end
def attributes_table_column_widths
# calculate fixed work package attribute table columns width
- widths = [1.0, 2.0, 1.0, 2.0] # label | value | label | value
+ widths = [1.5, 2.0, 1.5, 2.0] # label | value | label | value
ratio = pdf.bounds.width / widths.sum
widths.map { |w| w * ratio }
end
@@ -78,7 +78,7 @@ module WorkPackage::PDFExport::WorkPackageDetail
id
updated_at
type
- started_at
+ created_at
status
due_date
version
@@ -98,9 +98,9 @@ module WorkPackage::PDFExport::WorkPackageDetail
# get work package attribute table cell data: [label, value]
return ['', ''] if attribute.nil?
- label = WorkPackage.human_attribute_name(attribute) || ''
+ label = (WorkPackage.human_attribute_name(attribute) || '').upcase
[
- pdf.make_cell(label.upcase, attributes_table_label_font_style),
+ pdf.make_cell(label, attributes_table_label_font_style),
get_column_value_cell(work_package, attribute.to_sym)
]
end