[DRE-maint] Bug#955042: redmine: drag and drop of attachments does not work due to used jQuery version

Martin Gregoire mg at naymspace.de
Fri Mar 27 11:34:59 GMT 2020


Package: redmine
Version: 4.0.4-3~bpo10+1

Steps to reproduce:

- in a browser, open the Redmine page and log in
- visit any issue in any project
- edit the issue
- drag and drop an image file into the issue form


Expected behavior:

The issue form should change its color when dragging the file
(to give a visual hint that it's a valid drop target).
After dropping the file, it should be uploaded to the Redmine server
and shown in the attached files list in the issue form.


Current behavior:

When visiting the issue page, there is an error message
(in the browser console):

Uncaught TypeError: Cannot set property 'drop' of undefined
  at HTMLDocument.setupFileDrop

When dragging the file above the issue form, nothing happens.

After dropping the file, the browser will handle the file itself;
i.e. when dropping an image file, the browser will display the image.


Dependencies:

The redmine package depends on a jQuery package without a versioning:

$ apt show redmine
  Package: redmine
  Version: 4.0.4-3~bpo10+1
  Depends: ... libjs-jquery, ...

This package is resolved to:

$ apt show libjs-jquery
  Package: libjs-jquery
  Version: 3.3.1~dfsg-3

There is no other version available:

$ apt list -a libjs-jquery
  libjs-jquery/stable,now 3.3.1~dfsg-3 all [installed,automatic]

$ apt-cache madison libjs-jquery
  libjs-jquery | 3.3.1~dfsg-3 | http://deb.debian.org/debian buster/main
amd64 Packages


Issue:

Redmine v4.0.4 uses jQuery v1.11.1 currently, see
http://svn.redmine.org/redmine/tags/4.0.4/public/javascripts/jquery-1.11.1-ui-1.11.0-ujs-4.3.1.js.

In this jQuery version something called "fixHooks" is used to copy
properties from a
JavaScript Event to jQuery's Event; see this (outdated) guide:
https://learn.jquery.com/events/event-extensions/#jquery-event-fixhooks-object

This functionality was however removed in jQuery v3.0, see this guide:
https://jquery.com/upgrade-guide/3.0/#breaking-change-jquery-event-props-and-jquery-event-fixhooks-removed

Instead the original Event can be accessed as described here:
https://api.jquery.com/category/events/event-object/

The problem is the use of "fixHooks" in this file:
http://svn.redmine.org/redmine/tags/4.0.4/public/javascripts/attachments.js


Workaround:

I applied this workaround, and it seems to resolve the issue:

File public/javascripts/attachments.js

178c178
<   if ($.inArray('Files', e.dataTransfer.types) > -1) {
---
>   if ($.inArray('Files', e.originalEvent.dataTransfer.types) > -1) {
180c180
<     uploadAndAttachFiles(e.dataTransfer.files,
$('input:file.filedrop').first());
---
>     uploadAndAttachFiles(e.originalEvent.dataTransfer.files,
$('input:file.filedrop').first());
197,198d196
<
<     $.event.fixHooks.drop = { props: [ 'dataTransfer' ] };


More:

Redmine updated jQuery to v2.2.4 in v4.1.0. A Redmine contributor added
that they hope
to update jQuery to v3 or v4 in Redmine v4.2.0 or Redmine v5, see
https://redmine.org/issues/31196#note-4.


Kind regards,
Martin Gregoire
-- 
Martin Gregoire
Entwicklung

naymspace software GmbH & Co. KG
Krusenrotter Weg 65
24113 Kiel

Fon: +49 431 55 686 77-1
Fax: +49 431 55 686 77-9

E-Mail: martin.gregoire at naymspace.de
Internet: http://www.naymspace.de
Facebook: http://www.facebook.com/naymspace

Handelsregister Kiel
HRA 9607

Persönlich haftende Gesellschafterin:
naymspace Verwaltungsgesellschaft mbH
Sitz: Kiel
Geschäftsführer: Dennis Nissen
Handelsregister Kiel
HRB 18407


Informationen zum Datenschutz und Ihren Betroffenenrechten finden Sie
hier: https://www.naymspace.de/datenverarbeitungsinformation
.............................................................................................

Der Inhalt dieser E-Mail ist ausschließlich für den bezeichneten
Adressaten bestimmt.
Wenn Sie nicht der vorgesehene Adressat dieser E-Mail oder dessen
Vertreter sein sollten,
so beachten Sie bitte, dass jede Form der Kenntnisnahme,
Veröffentlichung, Vervielfältigung
oder Weitergabe des Inhalts dieser E-Mail unzulässig ist. Wir bitten
Sie, sich in diesem Fall
mit dem Absender der E-Mail in Verbindung zu setzen.

This e-mail and any files transmitted with it are confidental and
intended solely for the use
of the individual or organization to whom they are addressed. Should you
not be the intended
addressee of this e-mail or his representative, please note that
publication, replication of the
contents by any means or further communication of the content is not
permissible. Should
you have received this e-mail in error, please notify the sender.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pEpkey.asc
Type: application/pgp-keys
Size: 6409 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/pkg-ruby-extras-maintainers/attachments/20200327/17959120/attachment.key>


More information about the Pkg-ruby-extras-maintainers mailing list