Vote #81676
完了Paste image mixed with other DataTransferItem
0%
説明
It's been a few months that my Chrome (now Version 94.0.4606.81) cannot paste image when creating issue (with or without any Chrome extensions). I cannot reproduce with Firefox or not even Chromium. And I cannot pinpoint the reason why this problem started, but it has been consistently reproduced for months now, across multiple Chrome updates.
This is the JS error that occurs:
attachments.js?1591235575:275 Uncaught TypeError: Cannot read properties of null (reading 'name')
at HTMLDivElement.copyImageFromClipboard (attachments.js?1591235575:275)
at HTMLDivElement.dispatch (jquery-2.2.4-ui-1.11.0-ujs-5.2.3.js?1581467927:3)
at HTMLDivElement.r.handle (jquery-2.2.4-ui-1.11.0-ujs-5.2.3.js?1581467927:3)
This is if I @console.log(item)@ before the error occurs, for a single paste event:
DataTransferItem {kind: 'string', type: 'application/x-qt-image'}
DataTransferItem {kind: 'string', type: 'image/bmp'}
DataTransferItem {kind: 'string', type: 'image/cur'}
DataTransferItem {kind: 'string', type: 'image/ico'}
DataTransferItem {kind: 'string', type: 'image/jpeg'}
DataTransferItem {kind: 'string', type: 'image/jpg'}
DataTransferItem {kind: 'string', type: 'image/pbm'}
DataTransferItem {kind: 'string', type: 'image/pgm'}
DataTransferItem {kind: 'file', type: 'image/png'} <== Only item that makes sense
DataTransferItem {kind: 'string', type: 'image/ppm'}
DataTransferItem {kind: 'string', type: 'image/xbm'}
DataTransferItem {kind: 'string', type: 'image/xpm'}
Attached is the patch to safely fix this. It applies on current git master (8075884bc48deb3b7af94799d6eba943e999dcb2), or svn r21243.
journals
Could you show the detailed steps to reproduce the issue? I tried with Chome 94.0.4606.81 (macOS) but still cannot reproduce the issue. Does it depend on which application the image data is copied from?
--------------------------------------------------------------------------------
I use XUbuntu 20.04.3, and often take screenshot with https://github.com/flameshot-org/flameshot. The screenshot will go directly to clipboard which is super convenient to paste into Redmine. Unfortunately some colleagues run Ubuntu 20.04 (not XFCE) with Chrome(ium?) and cannot reproduced either. I am afraid that there is something specific in my setup that trigger the issue, but I cannot figure out what it is.
More importantly my screenshot can be pasted fine on github.com, or in Gimp. So it is somehow related to Redmine. And clipboard from Gimp will also *not* work on Redmine. So we can exclude flameshot as culprit.
Also see the reference there: https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/kind
I am quite confident that my patch will have no side-effect and might help others in the same (unusual?) situation as me.
I could show you a screencast of the whole thing, but I don't think there is anything relevant to see except the JS error I mentioned earlier.
--------------------------------------------------------------------------------
See here: https://i.imgur.com/jV4IiPT.mp4 (I could not upload here because it is slightly too big)
--------------------------------------------------------------------------------
Adrien Crivelli, thank you for your detailed report.
Could you try https://github.com/redmine/redmine/pull/129/files if the patch also fixes the issue in your environment?
--------------------------------------------------------------------------------
Yes, https://github.com/redmine/redmine/pull/129/files fixes the issue for me. Thank you for your time.
By the way is GitHub PR a new way to accept contributions ?
--------------------------------------------------------------------------------
Adrien Crivelli wrote:
> Yes, https://github.com/redmine/redmine/pull/129/files fixes the issue for me. Thank you for your time.
Thank you for testing the fix. I will commit one of the patches.
> By the way is GitHub PR a new way to accept contributions ?
No, the Redmine team does not accept pull requests (see https://github.com/redmine/redmine/blob/master/.github/PULL_REQUEST_TEMPLATE.md) but I just happened to find that pull request.
--------------------------------------------------------------------------------
Adrien, sorry for not including this ticket in the latest releases.
I'm not able to reproduce the issue on my local environment, but I made a patch that switches from @clipboardData.items@ to @clipboardData.files@ and that should fix your issue as well. Can you test it, please?
--------------------------------------------------------------------------------
Hello
I tested it, it works well, because I had this problem on chromium 95.0.4638.69,
but there is a problem, where there are two forms in the same page,
this problem will not exist if we replace the line (copyImageFromClipboard)
var inputEl = $('input:file.filedrop').first();
by var inputEl = $(this).closest("form").find('input:file.filedrop');
--------------------------------------------------------------------------------
On r21452, *without* patch, I am no longer able to reproduce the issue. It is likely that my brand new Chrome 99.0.4844.51 somehow fixed it.
So I cannot confirm for sure that the patch would fix the original issue, but I can confirm that *with* the patch it *also* works.
--------------------------------------------------------------------------------
Yazan Al aeddin wrote:
> Hello
> I tested it, it works well, because I had this problem on chromium 95.0.4638.69,
> but there is a problem, where there are two forms in the same page,
> this problem will not exist if we replace the line (copyImageFromClipboard)
> var inputEl = $('input:file.filedrop').first();
> by var inputEl = $(this).closest("form").find('input:file.filedrop');
Can you open a new issue with the steps to reproduce the problem?
--------------------------------------------------------------------------------
Adrien Crivelli wrote:
> On r21452, *without* patch, I am no longer able to reproduce the issue. It is likely that my brand new Chrome 99.0.4844.51 somehow fixed it.
>
> So I cannot confirm for sure that the patch would fix the original issue, but I can confirm that *with* the patch it *also* works.
Thanks Adrien! I've committed the change as a refactorization.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
related_issues
relates,Closed,36887,copyImageFromClipboard function failed to generate a unique file name