Bug 450492 - inconsistent / overlapping hyperlinking and previews for text in konsole
Summary: inconsistent / overlapping hyperlinking and previews for text in konsole
Status: REPORTED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: 21.08.1
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-02-17 22:13 UTC by Holger
Modified: 2022-02-17 22:13 UTC (History)
0 users

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


Attachments
a) URLs labeled 1 2 3 first take precedence, b) label 4 overlapped by label 1, c) no underline for explicit escape-sequence hyperlink (171.49 KB, image/png)
2022-02-17 22:13 UTC, Holger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Holger 2022-02-17 22:13:11 UTC
Created attachment 146896 [details]
a) URLs labeled 1 2 3 first take precedence, b) label 4 overlapped by label 1, c) no underline for explicit escape-sequence hyperlink

SUMMARY

Konsole tries to hyperlink URLs and filenames listed e.g. in ls output.
As per bug 379294 a third mechanism for hyperlink-escape sequences was added.

STEPS TO REPRODUCE
1. touch "www.example.com this is a green filename.txt"
2. printf '\e]8;;file://%s\e\\../other folder/ has no: %s\e]8;;\e\\\n' ~ ./www.example.com\ this\ is\ a\ green\ filename.txt

OBSERVED RESULT
1. "../other" is picked up as a folder-reference, but breaks at the space (this one doesn't get a number assigned)
2. "www.example.com" is picked up as a URL to www.example.com (this one gets a number assigned)
3. the whole hyperlink by escape sequence is not underlined on pressing Ctrl-Hotkey (only by mouse hover) AND not numbered, but correctly opens the Homefolder, if you click any character neither in 1 nor in 2.
4. Number assignment prefers URLs over ordinary files, even if they are further back in the output (see screenshot)
5. Escape-sequence-hyperlinks to file:/// are exempt from loading preview-thumbnails (in case of pictures)
6. hovering the keyword "green" shows a green square thumbnail in some places but not in others
7. It's impossible to open this textfile in kate (neither by any quotation, nor by listing it in any combination of options with ls)

EXPECTED RESULT
a) Never stack hyperlinks for the same chunk of text:
- explicit escape sequences shall disable any heuristic detection within
- outside escape sequences use the longer chunk (so if a filename incorporates a URL, still use the filename and not the shorter URL)
b) assign shortcut digits to links in sequence of appearance, not grouped by type
c) if ls output was detected, read the filename until the end of the line
d) if a filename is surrounded by quotation, look for the matching pair of 'x y.txt' or "z w.txt", also treat "\ " as continuing the filename. (Could also try to break chunks by color-changes at color escape sequence)
e) if a path was detected by a slash / try to read until end of line (but not more than e.g. 200 characters) and see, if it points to a file/folder (chop words from the end one by one, until the file/folder exists)
f) don't auto hyperlink filenames, that don't exist
g) color preview only outside of other links (least useful = least priority) - but could also try to preview escape sequences like: printf '_\033[33m_this is not lightgreen\033[m\n'
when hovering anywhere between the underscores _
h) support preview-thumbnails for escape sequence hyperlinks to file:///
i) support underline-highlight for escape sequence hyperlinks (without mouse hover)
j) http(s) URLs should show the browser-icon along with the invisible target-URL

SOFTWARE/OS VERSIONS
Operating System: Kubuntu 21.10
KDE Plasma Version: 5.22.5
KDE Frameworks Version: 5.86.0
Qt Version: 5.15.2
Kernel Version: 5.13.0-28-generic (64-bit)
Graphics Platform: X11
Processors: 8 × Intel® Core™ i7-4700MQ CPU @ 2.40GHz
Memory: 15.5 GiB of RAM
Graphics Processor: Mesa DRI Intel® HD Graphics 4600

ADDITIONAL INFORMATION

- Yes, I saw the security concerns about malicious links - adding a preview hover of the URL, what is going to open shall help to mitigate it.
- Trying to resolve file-existence could be a performance hit on accessing a slow network drive. It might be an idea to measure the time spent and abort after e.g. 100ms. OTH with my several years old SSD, I can lookup file-attributes for hundreds of files in less than a second.
- chopping single words for path detection as in e) might not be efficient. Instead Konsole could first chop at slashes / and try to do a divided&conquer -> if half the path works immediately, no need to test substrings of it.