Bug 487151 - Unable to open a file ending in :0 from an sftp: location
Summary: Unable to open a file ending in :0 from an sftp: location
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: application (other bugs)
Version First Reported In: 24.02.2
Platform: Neon Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-17 15:53 UTC by TrianguloY
Modified: 2024-12-30 19:24 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description TrianguloY 2024-05-17 15:53:11 UTC
SUMMARY

If you try to open a file from a sftp: location that ends with :0, that suffix is removed and kate tries to open the file without it instead.


STEPS TO REPRODUCE
1. Run the following command: `sftp://invalid/test:0`
2. Wait for kate to open. Ignore the 'Failed to resolve hostname invalid (Name or service not known)' message. Press ok to dismiss
3. Check the file that was opened (if you have tabs you can hover on it for the full path)

OBSERVED RESULT
The full path that kate tried to open is `sftp://invalid/test`

EXPECTED RESULT
The full path tha kate should open is `sftp://invalid/test:0`

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: KDE neon 6.0
KDE Plasma Version: 6.0.4
KDE Frameworks Version: 6.1.0
Qt Version: 6.7.0

ADDITIONAL INFORMATION
- Even though the example uses an invalid hostname and an invalid file, you can use a real sftp file with that extension (that's how I discovered it on the first place). You'll see that kate still tries to open the invalid file, and if you do have that file it will be opened instead!
- Only numbers seems to be removed, and up to two suffixes: `sample:0` -> `sample`; `sample:a` -> `sample:a`; `sample:1:2` - > `sample`; `sample:1:2:3` - > `sample:1`;
- If the file name is just `:0`, kate will try to open the folder
Comment 1 TrianguloY 2024-05-17 15:55:01 UTC
I apologize, the reported command was missing the kate action.
I can't see how to edit the original comment, in the meantime here is the typo:

Where it says
1. Run the following command: `sftp://invalid/test:0`
It should say instead
1. Run the following command: `kate sftp://invalid/test:0`

Apologize again for the mistake
Comment 2 Christoph Cullmann 2024-12-01 14:10:30 UTC
We parse that as line number. A question is if we really should do that for non-local files...
Comment 3 TrianguloY 2024-12-02 17:24:45 UTC
Oh, thanks for the review. That would explain it, but, is that a documented feature? I can't see anything on the web documentation (https://docs.kde.org/stable5/en/kate/kate/fundamentals.html#starting-from-the-command-line) nor on the command line help (with kate -h) where the official parameters are apparently "-l, --line <line> Navigate to this line." and "-c, --column <column> Navigate to this column."

I also tested with a local file, and it works if the file does exist, but will remove the prefix if not. So:
$ kate './test:0'
will open a file called test:0 if it exists. But if the file does not exists, it will open an empty new file called test.

With sftp it will always remove the prefix, no matter if the file exists or not.

I think this also happens with http urls, but I couldn't perform proper tests with that.
Comment 4 Christoph Cullmann 2024-12-02 19:30:06 UTC
That is not documented explicitly. And yes, for local files existence tests are done.
Comment 5 Bug Janitor Service 2024-12-29 19:06:44 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kate/-/merge_requests/1683
Comment 6 Christoph Cullmann 2024-12-30 18:33:38 UTC
Git commit d8efd6c1ce34e14aed4b28d6f848fca65259fe3e by Christoph Cullmann.
Committed on 30/12/2024 at 17:54.
Pushed by cullmann into branch 'master'.

don't cut :x:y cursor info from remote urls

we do no check if the full url is existing

M  +5    -2    apps/lib/autotests/urlinfo_test.cpp
M  +17   -11   apps/lib/urlinfo.h

https://invent.kde.org/utilities/kate/-/commit/d8efd6c1ce34e14aed4b28d6f848fca65259fe3e
Comment 7 TrianguloY 2024-12-30 18:41:55 UTC
Thank you for the review and the fix! 
Much appreciated 😊
Comment 8 Christoph Cullmann 2024-12-30 19:24:07 UTC
Thanks for reporting this, guess we didn't think about that case in the past properly.