exceljs / exceljs

Excel Workbook Manager

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hyperlink with query arguments corrupts workbook

maksimlikharev opened this issue · comments

Found quite nasty bug.
If you include xml unsafe characters into url, resulted workbook is not readable,
this is especially true if you have query params where & is a separator.

This is due to relation target stored in the xml attribute.

following chars must be xml encoded:

"  
'   
<  
>  
&  

@maksimlikharev I've just tried to reproduce this and I'm having trouble...
The following (unlikely) hyperlink saves fine and opens in Excel:

    ws.getCell('A1').value = {
      text:'Somewhere with query params',
      hyperlink: 'www.somewhere.com?a=1&b=2&c=<>&d="\'"'
    };

Could you post some example code that causes your issue?

This is what we do.

exceljs: 0.3.0

One important detail I forgot to mention, this is streaming mode.

let rowData = {};

rowData['url'] = { text: 'text', hyperlink: 'http://localhost/getsome?sss=1&bbb=2&ccc=<>' }

this.workbook.getWorksheet(1).addRow(rowData);

row.commit();

@maksimlikharev - just pushed 0.4.1 with a fix.
Thanks for raising this :-)
Let me know if this fixes your issue