Bug 507952 - KTextToHTML::convertToHtml prints broken HTML if given URL ends with a double-quote
Summary: KTextToHTML::convertToHtml prints broken HTML if given URL ends with a double...
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kcoreaddons
Classification: Frameworks and Libraries
Component: general (other bugs)
Version First Reported In: 6.18.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Michael Pyne
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-08-06 20:02 UTC by Antti Savolainen
Modified: 2025-10-03 21:52 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.19
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Antti Savolainen 2025-08-06 20:02:05 UTC
SUMMARY
Demonstrative video: https://youtu.be/sBl0kbedNi0
If I copy text that contains file:///..." the text doesn't paste into sticky notes. The ellipsis can be swapped with any text and the trailing " must be there

STEPS TO REPRODUCE
1. Copy text that contains file:///..."
2. Try to paste it to a sticky note

OBSERVED RESULT
Text doesn't paste

EXPECTED RESULT
Text should get pasted

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.4.80
KDE Frameworks Version: 6.18.0
Qt Version: 6.10.0
Kernel Version: 6.16.0-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 4 × Intel® Core™ i7-7600U CPU @ 2.80GHz
Memory: 24 GiB of RAM (23.2 GiB usable)
Graphics Processor: Intel® HD Graphics 620
Manufacturer: LENOVO
Product Name: 20HG0003SG
System Version: ThinkPad T470s
Comment 1 Nate Graham 2025-08-07 16:46:45 UTC
Wow, you're right. How odd!
Comment 2 lkorbel 2025-08-15 06:33:24 UTC
With all the respect I believe this is the expected result.

Widget auto detects links in copied text so they are formatted properly and can be opened (sic!). Since in URI standard quotation mark is treated as a special sign it must be percent encoded. Therefore proper file URI string will contain ```%22``` instead of ```"```.

This work as intended if you use dolphin to copy file - simply copy the file you want a proper uri is available in clipboard so you can paste it wherever its needed including notes widget. It automatically percent-encode the text if needed. This applies to more then quotation mark sign. There whole bunch that need to be encoded.

One can argue that invalid URIs should still be copied as they are without formatting but it also opens gate to other problems like: "hey, I paste file:// (or https:// or whatever) link and it is not recognized".  Or if we treat such invalid text as link anyway then "Hey, I click on the link and it does not work". Therefore I see merits in current solution.
Comment 3 Antti Savolainen 2025-08-15 15:10:40 UTC
My use case here was that I was trying to paste arch install steps to my notepad so that I could quickly copy them back to the terminal. This was the line that I tried to paste: 
echo "Server = file:///srv/http" >> /etc/pacman.conf
Comment 4 lkorbel 2025-08-22 03:28:59 UTC
(In reply to Antti Savolainen from comment #3)
> My use case here was that I was trying to paste arch install steps to my
> notepad so that I could quickly copy them back to the terminal. This was the
> line that I tried to paste: 
> echo "Server = file:///srv/http" >> /etc/pacman.conf

I've just tested it and it's indeed annoying when you copy large parts of text and some of it is simply dropped. What would work better is if underlying processor just left plain text as it is if link is not detected as valid.

It is possible though to paste text from your example by choosing option "Paste with Full Formatting" from context menu. It's just not the default option under Ctrl+V shortcut.
Comment 5 Bug Janitor Service 2025-10-01 09:31:10 UTC Comment hidden (spam)
Comment 6 Bug Janitor Service 2025-10-01 10:16:47 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kcoreaddons/-/merge_requests/535
Comment 7 Akseli Lahtinen 2025-10-03 09:22:11 UTC
Git commit 59e48d72bfd997a624549ed814397287cf095fea by Akseli Lahtinen.
Committed on 03/10/2025 at 09:13.
Pushed by akselmo into branch 'master'.

KTextToHtml: If URL ends with double-quote, it's not valid URL

In cases where URL does NOT start with double-quote, but ends with one,
such as `file:///srv/http"`,
mark the url as "badUrl".

M  +4    -0    autotests/ktexttohtmltest.cpp
M  +7    -0    src/lib/text/ktexttohtml.cpp

https://invent.kde.org/frameworks/kcoreaddons/-/commit/59e48d72bfd997a624549ed814397287cf095fea