You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2015-06-18 16:58:39

stoatwblr
Member
Registered: 2014-04-13
Posts: 118

document attachments - file corruption issue

pptx files attached to tickets are downloaded with leading padding characters, which means libreoffice can't open them.

At this point I don't know if the corruption is occuring at upload or download.

0.85.4

Last edited by stoatwblr (2015-06-18 16:58:56)

Offline

#2 2015-06-18 17:02:17

stoatwblr
Member
Registered: 2014-04-13
Posts: 118

Re: document attachments - file corruption issue

The padding is 2 CTRL-M ("^M") characters and it is happening when the files are downloaded.

Files in /var/lib/glpi/files/PPTX/* are undamaged.

This is also happening on docx and png files, so I suspect it's happening on everything downloaded.


Windows/MSOffice detects the files are damaged and is able to repair+open them, but Linux/libreoffice cannot cope with the munging.

Last edited by stoatwblr (2015-06-29 16:20:19)

Offline

#3 2015-06-19 11:07:37

yllen
GLPI-DEV
From: Sillery (51)
Registered: 2008-01-14
Posts: 15,278

Re: document attachments - file corruption issue

With LO you have problem to open pptx and docx but i don't remember in which version.
Can you open this kind of file before uploading them?


CentOS 6.5 - CentOS 7.x
PHP 5.6 - PHP 7.x - MySQL 5.6  - MariaDB 10.2 + APC + oOPcache
GLPI from 0.72 to dev version
Certifiée ITIL (ITV2F, ITILF, ITILOSA)

Offline

#4 2015-06-29 16:19:08

stoatwblr
Member
Registered: 2014-04-13
Posts: 118

Re: document attachments - file corruption issue

Yes, LO was able to open the original files happily

The files are intact on the GLPI server's disk  (ie: in /var/lib/glpi/files/*/*). The CTRL-Ms are prepended to the files at the point of download from GLPI.

Last edited by stoatwblr (2015-06-29 16:19:52)

Offline

#5 2015-07-01 01:05:43

stoatwblr
Member
Registered: 2014-04-13
Posts: 118

Re: document attachments - file corruption issue

This is happening in other parts of glpi - user images and ticket timeline graphics are also suffering the problem.

Offline

#6 2015-07-03 03:52:27

stoatwblr
Member
Registered: 2014-04-13
Posts: 118

Re: document attachments - file corruption issue

According to various PHP forums, this mind of thing is usually caused by LFs in PHP code where they shouldn't be.

In particular: There are warnings against trailing LFs in .php files after the closing "?>" statement

GLPI and plugins have a few such files. It may be worthwhile adding a sanity check to ensure they aren't allowed in git

(Removing the trailing LFs doesn't fix this problem, but might avoid future ones. I'm still looking for the source of the prepended LFs)

Offline

#7 2015-07-03 16:55:41

stoatwblr
Member
Registered: 2014-04-13
Posts: 118

Re: document attachments - file corruption issue

I think this is similar to an old issue reported against 0.73

http://www.glpi-project.org/forum/viewt … p?id=15698

Note that 2 fixes were found there -

firstly, eliminating blank lines before <?php and after ?>

secondly by adding

ob_clean();
flush();

Both are recommendations on PHP lists for this kind of issue.

I have checked all php files and found/removed  quite a few trailing LFs after ?>, however the problem remains.

Interestingly, the dashboard plugin uses a mixture of PHP and static html, with the html after the end of the PHP statement. This is a different style to the rest of the php files and I'm not sure if it is important or not. Removing the plugin makes no difference anyway.

Last edited by stoatwblr (2015-07-03 17:04:47)

Offline

#8 2015-07-03 17:49:22

stoatwblr
Member
Registered: 2014-04-13
Posts: 118

Re: document attachments - file corruption issue

Maybe some more help in finding the cause:

_everything_ being output by GLPI has 2 leading LFs on it. HTML doesn't care about this but when the client is expecting a binary file, what it received is what gets written to disk,

Offline

#9 2015-07-03 19:43:16

stoatwblr
Member
Registered: 2014-04-13
Posts: 118

Re: document attachments - file corruption issue

Solved, thanks to Remi.

The problem is the exportXL plugin

exportxl/locales/fr_FR.php exportxl/locales/en_US.php and exportxl/locales/en_GB.php all have trailing LFs

Removing those solved the problem.

it does raise another issue:

Remi pointed out  https://forge.indepnet.net/projects/glp … nd_file.pl

This finds a _lot_ of problems with plugins - mostly these are files unterminated with ?> (which is OK per the newest PHP standard) but quite a few are in DOS format (need hitting with dos2unix) and a few have genuine open/close problems.

These plugins really need bug reports raised against them but I don't have suffficient access on the forge to create tickets.

Offline

Board footer

Powered by FluxBB