Defect #36887

copyImageFromClipboard function failed to generate a unique file name

Added by Simon Hori about 1 month ago. Updated 25 days ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Marius BALTEANU% Done:

0%

Category:Attachments
Target version:4.2.6
Resolution:Fixed Affected version:

Description

Hello,

The function copyImageFromClipboard is NOT generating unique file name but always uploading image.png.

I've confirmed the problem in chrome 99.0.4844.74, edge 100.0.1185.29, firefox 98.0.2.

This is our environment.

Environment:
  Redmine version                4.2.5.stable
  Ruby version                   2.6.9-p207 (2021-11-24) [x86_64-linux-musl]
  Rails version                  5.2.6.3
  Environment                    production
  Database adapter               PostgreSQL
  Mailer queue                   ActiveJob::QueueAdapters::AsyncAdapter
  Mailer delivery                smtp

Possible reason:

According from the public/javascripts/attachments.js#L283-L291 I felt that the variable 'filename' is defined but not used. Can it be the reason of this behavior?

Thank you very much for your support.

clipboardimage.jpg (49.6 KB) Simon Hori, 2022-04-04 09:24

0001-Fix-copyImageFromClipboard-function-failed-to-genera.patch Magnifier (847 Bytes) Marius BALTEANU, 2022-04-04 20:19

after-the-patch.jpg (56.6 KB) Simon Hori, 2022-04-05 02:32


Related issues

Related to Redmine - Defect #36013: Paste image mixed with other DataTransferItem Closed
Duplicated by Redmine - Defect #36911: Clipboard copy is broken after upgrade to 4.2.5 or 5.0.0 ... Closed
Copied from Redmine - Patch #36817: copyImageFromClipboard function targets the first file in... Closed

Associated revisions

Revision 21523
Added by Marius BALTEANU about 1 month ago

Fix that copy paste image from clipboard fails to generate a unique file name (#36887).

Revision 21530
Added by Marius BALTEANU about 1 month ago

Merged r21523 to 5.0-stable (#36887).

Revision 21531
Added by Marius BALTEANU about 1 month ago

Merged r21523 to 4.2-stable (#36887).

History

#1 Updated by Simon Hori about 1 month ago

  • Copied from Patch #36817: copyImageFromClipboard function targets the first file input of the page and may conflict with other plugins added

#2 Updated by Simon Hori about 1 month ago

I am sorry Marius BALTEANU. Maybe I shouldn't have copied #36817 with the target version and the assignee. Please let me know if I should create a new issue from scratch.

#3 Updated by Marius BALTEANU about 1 month ago

  • Status changed from New to Confirmed

#4 Updated by Marius BALTEANU about 1 month ago

  • File 0001-Fix-copyImageFromClipboard-function-failed-to-genera.patch added

Simon, thanks for reporting this! Can you test the attached fix?

#5 Updated by Marius BALTEANU about 1 month ago

  • File deleted (0001-Fix-copyImageFromClipboard-function-failed-to-genera.patch)

#7 Updated by Simon Hori about 1 month ago

Awesome!! It works, thank you so much for the quick fix.

Screenshot

#8 Updated by Marius BALTEANU about 1 month ago

  • Status changed from Confirmed to Resolved
  • Resolution set to Fixed

#9 Updated by Marius BALTEANU about 1 month ago

Fix committed, thanks!

#10 Updated by Go MAEDA about 1 month ago

  • Related to Defect #36911: Clipboard copy is broken after upgrade to 4.2.5 or 5.0.0 from 4.2.3 added

#11 Updated by Go MAEDA about 1 month ago

  • Related to deleted (Defect #36911: Clipboard copy is broken after upgrade to 4.2.5 or 5.0.0 from 4.2.3)

#12 Updated by Go MAEDA about 1 month ago

  • Duplicated by Defect #36911: Clipboard copy is broken after upgrade to 4.2.5 or 5.0.0 from 4.2.3 added

#13 Updated by Go MAEDA about 1 month ago

  • Related to Defect #36013: Paste image mixed with other DataTransferItem added

#14 Updated by Marius BALTEANU about 1 month ago

Merged to stable branches, but I will keep this open for a few days, I would like to try add a system test.

#15 Updated by Marius BALTEANU 25 days ago

  • Status changed from Resolved to Closed

I didn't find a way to add a test for this, any help is welcome.

Also available in: Atom PDF