reports: URL-quote file links in spreadsheets. RT#12517

This was already done correctly in RT links because rtutil takes care of the
quoting. The fact that we weren't doing it for file links was an oversight.
This commit is contained in:
Brett Smith 2020-09-05 14:47:34 -04:00
parent de10197af7
commit c2851f5cc0
2 changed files with 6 additions and 1 deletions

View file

@ -1172,7 +1172,7 @@ class BaseODS(BaseSpreadsheet[RT, ST], metaclass=abc.ABCMeta):
# '..' pops the ODS filename off the link path. In other words, # '..' pops the ODS filename off the link path. In other words,
# make the link relative to the directory the ODS is in. # make the link relative to the directory the ODS is in.
href_path = Path('..', href) href_path = Path('..', href)
href = str(href_path) href = urlparse.quote(str(href_path))
text = href_path.name text = href_path.name
else: else:
rt_path = urlparse.urlparse(rt_href).path rt_path = urlparse.urlparse(rt_href).path

View file

@ -617,6 +617,7 @@ def test_ods_writer_meta_links_cell(ods_writer):
'rt://ticket/2/attachments/9', 'rt://ticket/2/attachments/9',
'rt:1/5', 'rt:1/5',
'Invoices/0123.pdf', 'Invoices/0123.pdf',
'Invoice #789.pdf',
] ]
cell = ods_writer.meta_links_cell(meta_links, stylename='meta1') cell = ods_writer.meta_links_cell(meta_links, stylename='meta1')
assert cell.getAttribute('valuetype') == 'string' assert cell.getAttribute('valuetype') == 'string'
@ -642,6 +643,10 @@ def test_ods_writer_meta_links_cell(ods_writer):
expect_url = f'../{meta_links[3]}' expect_url = f'../{meta_links[3]}'
assert child.getAttribute('href') == expect_url assert child.getAttribute('href') == expect_url
assert get_text(child) == '0123.pdf' assert get_text(child) == '0123.pdf'
child = next(children)
assert child.getAttribute('type') == 'simple'
assert child.getAttribute('href') == '../Invoice%20%23789.pdf'
assert get_text(child) == 'Invoice #789.pdf'
def test_ods_writer_multiline_cell(ods_writer): def test_ods_writer_multiline_cell(ods_writer):
cell = ods_writer.multiline_cell(iter(STRING_CELL_DATA)) cell = ods_writer.multiline_cell(iter(STRING_CELL_DATA))