Extension - Templates in docx format - corrupted file when & is saved in field type entity

Post Reply
swar
Posts: 60
Joined: 19 Dec 2020, 04:11
Name: A.R.
Location: Bratislava

Extension - Templates in docx format - corrupted file when & is saved in field type entity

Post by swar »

This is more less the same bug that was already reported in the past (viewtopic.php?f=20&t=3242&p=13048), however, now it affects only field type entity.


Where: ext/templates/export_templates - docx template (https://docs.rukovoditel.net/index.php?p=100)

What: In case there is a character & in name of record linked via field type entity and field type entity is used as information block in docx template, the exported docx is corrupted.

How replicate:
1. Create an entity Projects and Companies.
2. Add field Asignee (type entity) to Projects and chose Select Entity: Companies.
3. Create a docx template for entity Projects and insert block for field Asignee in the docx template (e.g. Asignee: ${78}).
4. Create a new record in entity Companies with field name "A&B" or any other name with &.
5. Create a new record in Projects and select Asignee: "A&B".
5. Try exporting newly saved record in Projects to docx template. The file is corrupted.
6. Delete character & from name of the record in Companies and try exporting Projects again. Now the file is ok.
User avatar
support
Site Admin
Posts: 6215
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: Extension - Templates in docx format - corrupted file when & is saved in field type entity

Post by support »

I think I have found issue. File from archive replace to plugins\ext\classes\templates\
Let me know if it works ok now.
Attachments
export_templates_blocks_fix1.zip
(10.89 KiB) Downloaded 112 times
brave
Sponsor
Sponsor
Posts: 180
Joined: 17 Jul 2016, 12:34
Name: Patrick
Location: Germany

Re: Extension - Templates in docx format - corrupted file when & is saved in field type entity

Post by brave »

it did not work for me, the word document cannot be opened. Do I change it back to & you can open the worddocment. it's about A&B for me I have to write A&B
User avatar
support
Site Admin
Posts: 6215
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: Extension - Templates in docx format - corrupted file when & is saved in field type entity

Post by support »

Patrick, you have applied this patch?
If so then please reproduce issue on personal demo https://www.rukovoditel.net/account_dem ... quest=demo
and give me the link to the demo. I will look where issue is.
swar
Posts: 60
Joined: 19 Dec 2020, 04:11
Name: A.R.
Location: Bratislava

Re: Extension - Templates in docx format - corrupted file when & is saved in field type entity

Post by swar »

The patch above solved the problem in our use case. Thanks, Sergey!
User avatar
support
Site Admin
Posts: 6215
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: Extension - Templates in docx format - corrupted file when & is saved in field type entity

Post by support »

Patrick, I have found your issue. File from attached archive replace to plugins\ext\classes\templates\
Let me know if it's fixed.
Attachments
export_templates_blocks_fix2.zip
(10.9 KiB) Downloaded 122 times
brave
Sponsor
Sponsor
Posts: 180
Joined: 17 Jul 2016, 12:34
Name: Patrick
Location: Germany

Re: Extension - Templates in docx format - corrupted file when & is saved in field type entity

Post by brave »

it works!! Sergey you are a genius! Thank you very much
Post Reply