Changeset - c2851f5cc08b
[Not reviewed]
0 2 0
Brett Smith - 4 years ago 2020-09-05 18:48:48
brettcsmith@brettcsmith.org
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.
2 files changed with 6 insertions and 1 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/reports/core.py
Show inline comments
...
 
@@ -1172,7 +1172,7 @@ class BaseODS(BaseSpreadsheet[RT, ST], metaclass=abc.ABCMeta):
 
                # '..' pops the ODS filename off the link path. In other words,
 
                # make the link relative to the directory the ODS is in.
 
                href_path = Path('..', href)
 
                href = str(href_path)
 
                href = urlparse.quote(str(href_path))
 
                text = href_path.name
 
            else:
 
                rt_path = urlparse.urlparse(rt_href).path
tests/test_reports_spreadsheet.py
Show inline comments
...
 
@@ -617,6 +617,7 @@ def test_ods_writer_meta_links_cell(ods_writer):
 
        'rt://ticket/2/attachments/9',
 
        'rt:1/5',
 
        'Invoices/0123.pdf',
 
        'Invoice #789.pdf',
 
    ]
 
    cell = ods_writer.meta_links_cell(meta_links, stylename='meta1')
 
    assert cell.getAttribute('valuetype') == 'string'
...
 
@@ -642,6 +643,10 @@ def test_ods_writer_meta_links_cell(ods_writer):
 
    expect_url = f'../{meta_links[3]}'
 
    assert child.getAttribute('href') == expect_url
 
    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):
 
    cell = ods_writer.multiline_cell(iter(STRING_CELL_DATA))
0 comments (0 inline, 0 general)