Truncate url string in KIO::job description to avoid freezing up plasma notification
ClosedPublic

Authored by yuenlim on Mar 11 2017, 12:48 PM.

Details

Summary

When posting large raw image data to imgur in QuickShare, the KIO job ends up triggering a notification that displays the entire raw image data, causing plasma to freeze:

"Transferring: Finished" "data:image/png;base64, <the entire raw data of the image to paste>"

see D4945 for details.

This patch truncates the url string assigned to the job description at 100 characters and so limits the length of the string that gets sent to the notification.

Only emitTransferring() is related to the issue I'm trying to fix, but it looked like it was probably sensible to apply the same treatment in the other cases of assigning url string to description as well, so I did.

Very unfamiliar with the code here! Would appreciate comments for improving the patch. Also not sure who are the right reviewers for this so please add if I missed it out.

Test Plan

With a 3000x2000 display and using a blank desktop with the "Evening Glow by Ian Hex" wallpaper.

  1. Take a screenshot of the whole blank desktop with Spectacle
  2. Click "Copy to Clipboard"
  3. Right click QuickShare plasmoid > Paste
  4. Select Imgur action

Before: plasma becomes unresponsive, shell output should indicate the notification as in description.

After: Plasma does not become unresponsive, notification shows with truncated string.

Diff Detail

Repository
R241 KIO
Lint
Lint Skipped
Unit
Unit Tests Skipped
yuenlim created this revision.Mar 11 2017, 12:48 PM
Restricted Application added projects: Plasma, Frameworks. · View Herald TranscriptMar 11 2017, 12:48 PM
Restricted Application added subscribers: Frameworks, plasma-devel. · View Herald Transcript
dfaure added a subscriber: dfaure.Mar 11 2017, 1:07 PM

Can you use KStringHandler::csqueeze ? This way filenames are still visible.

yuenlim updated this revision to Diff 12391.Mar 11 2017, 5:00 PM

Use KStringHandler::csqueeze for truncating!

dfaure accepted this revision.Mar 11 2017, 7:09 PM

Extra credit for factorizing this into a file-static function and handling data: URLs separately (no point in seeing 100 chars of data crap, we could do data:[...] or something like that).

This revision is now accepted and ready to land.Mar 11 2017, 7:09 PM
yuenlim updated this revision to Diff 12403.Mar 12 2017, 7:25 AM

Something like this?

Yes; looks much nicer, doesn't it?

src/core/job_p.h
76 ↗(On Diff #12380)

This can now be moved to the helper function.

This revision was automatically updated to reflect the committed changes.