nilsteampassnet / TeamPass

Collaborative Passwords Manager
https://www.teampass.net
1.66k stars 542 forks source link

Broken CSV entries export when the field "Description" contains Enter (<br /> and <br> tag) and Lists #3484

Closed eduardomozart closed 1 year ago

eduardomozart commented 1 year ago
### Steps to reproduce 1. Enable "Export to PDF or CSV enabled" and setup it's Roles as expected. 2. Login with the user with an authorized Role to export as PDF/CSV. 3. Go to "Export" pages and export all as CSV. ### Expected behaviour When the "Description" field contains Enter (``
tag``), Teampass should remove the "Enter" so it would export as expected. ### Actual behaviour image The item was exported with the following line at the CSV: ``` 162,"VPN - XXX - Fortgate (Terceirizada)","VPN: SSL-VPN ``` It's simply broken and every other information after it (like username and password) is missing from the exported CSV file. I could filter wrong exported entries (into my case) by finding lines that do not end with one comma at the end with the following RegEx: ``` .*(?
eduardomozart commented 1 year ago

It seems that only items migrated from Teampass 2.x -> Teampass 3.x is affected. When I edited the Description field to redo the "Enters", it saved as Paragraphs (paragraphs between <p></p> tags) and they were exported as expected. I believe that for Enters the Teampass 2.x used <br /> tags instead. Not sure, but I believe this issue while parsing <br /> and List tags maybe related to the cleanString function from the main.functions.php file (as can be seen https://github.com/nilsteampassnet/TeamPass/blob/e9f7e3772b65a7dd943782418236a2ca154eecad/sources/main.functions.php).

eduardomozart commented 1 year ago

It seems to strip <br> tags (Shift + Enter) when exporting, only <br /> tag (items "Description" migrated from Tempass 2.x) seems to fail.

Before updating the Description field:

210,"Switch 3Com 1910","Necess&aacute|rio alterar o campo Bits por segundo da porta COM para 38400 no Gerenciador de dispositivos para acesso Console.

After upgrading the Description field:

210,"Switch 3Com 1910","Necess?rio alterar o campo Bits por segundo da porta COM para 38400 no Gerenciador de dispositivos para acesso Console.Para habilitar a execu??o de todos os comandos, execute no terminal:_cmdline-mode onPlease input password:&nbsp|512900",(semsenha),admin,,False,,,,
eduardomozart commented 1 year ago

It also seems to fail to parse the CSV output when the item Description field contains a list created by the HTML editor available from the field, e.g.:

<p>Endereços externos:</p><ul><li>https://rnetworks.example.com:5001/</li><li>https://voip.example.com:5001/</li></ul>

CSV output:

225,"3CX PABX","Endere?os externos:

eduardomozart commented 1 year ago

<br> strings is also broken while exporting, e.g.:

Description field:

Virtual: 1.2.3.10/24<br>WLC1: 1.2.3.11/24<br>WLC2: 1.2.3.12/24

CSV output:

285,"Virtual Controller : 1.2.3.10/24","Virtual: 1.2.3.10/24

It only exports as expected when it's between <p> tags, e.g.:

Description field:

<p>Virtual: 1.2.3.10/24<br>WLC1: 1.2.3.11/24<br>WLC2: 1.2.3.12/24</p>

CSV output:

285,"Virtual Controller : 1.2.3.10/24","Virtual: 1.2.3.10/24WLC1: 1.2.3.11/24WLC2: 1.2.3.12/24",aruba123,admin,,False,,,,
nilsteampassnet commented 1 year ago

A fix has been committed. Please reopen if needed.