Issue 333 Note Attachments Downloaded - edmozley/freeitsm GitHub Wiki
๐ #333 A file attached to a ticket note downloaded instead of opening in the preview
GitHub #333, reported by pappas81 ยท Tickets ยท since 5.2.0, fixed in 5.3.0 (#2906)
What you saw
In a ticket, a file attached to a note - a CSV, a Word document, a text file - downloaded when you clicked it. The same kind of file in the ticket's Attachments, a task's attachments or a Documents panel opened in the preview window, with a Download button in it.
What was wrong
Two rules decided which files open in the viewer, and they had drifted apart:
| Where | Rule | Opened in the viewer |
|---|---|---|
A ticket's attachments (openAttachment) |
everything except zip and svg (ATTACHMENT_NO_VIEWER_RE) |
pictures, PDFs, Word, spreadsheets and CSV, text, audio, video |
A note's files (renderNotes) |
pictures and PDFs only (VIEWER_FILE_RE) |
pictures, PDFs |
The note rule dates from #226, when the viewer showed little more than pictures and PDFs. #303 (5.2.0) widened the attachments rule to everything the viewer can show - also at pappas81's request - but the note rule was not changed with it.
The fix
A note's files use the attachments rule. The viewer still decides by the file's name what it can draw, and anything it cannot show (or a zip, or an SVG, which can carry script) downloads as before. The old VIEWER_FILE_RE is gone, and a TRAP: comment says the two must stay one rule.
๐ Files
| File | Change |
|---|---|
assets/js/inbox.js |
note files: !ATTACHMENT_NO_VIEWER_RE.test(name); VIEWER_FILE_RE removed |
tickets/index.php |
inbox.js?v=207 |
How it was verified
On the real Tickets page, a note holding data.csv, report.docx, photo.png and pack.zip was drawn: the CSV, the Word document and the picture are handed to the viewer, the zip downloads, and the viewer accepts the CSV. No script errors.
What this means for you
Update to 5.3.0 and a note's files preview like every other attachment.
Related: Tickets ยท #303 Documents open in place