Bug 510863 - LSP Client does not do url encode to the value of rootUri
Summary: LSP Client does not do url encode to the value of rootUri
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: general (other bugs)
Version First Reported In: 25.08.2
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-10-21 11:48 UTC by ZhangHua
Modified: 2025-10-23 16:42 UTC (History)
0 users

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 ZhangHua 2025-10-21 11:48:06 UTC
SUMMARY
Kate's LSP Client does not do url encode to the value of `rootUri`, which may break some LSP servers when there contains non-ascii characters.

STEPS TO REPRODUCE
1. Setup [zuban](https://github.com/zubanls/zuban), a Python LSP server implementation.
2. Launch kate and open a python project which has non-ascii characters in the path. For example, `/home/zhanghua/文档/repositories/git/github.com/aumir` is my project root.
3. See zuban failed to start.

OBSERVED RESULT
zuban failed to start, only this is in the server output:
Failed to deserialize InitializeParams: unexpected character at index 22; {"capabilities":{"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix","refactor","source"]}}},"completion":{"completionItem":{"resolveSupport":{"properties":["additionalTextEdits","documentation"]},"snippetSupport":true}},"documentSymbol":{"hierarchicalDocumentSymbolSupport":true},"hover":{"contentFormat":["markdown","plaintext"]},"inlayHint":{"dynamicRegistration":false},"publishDiagnostics":{"relatedInformation":true},"selectionRange":{"dynamicRegistration":false},"semanticTokens":{"formats":["relative"],"requests":{"full":{"delta":true},"range":true},"tokenModifiers":[],"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","macro","keyword","modifier","comment","string","number","regexp","operator"]},"synchronization":{"didSave":true}},"window":{"showMessage":{"messageActionItem":{"additionalPropertiesSupport":true}},"workDoneProgress":true}},"processId":67782,"rootPath":"/home/zhanghua/文档/repositories/git/github.com/aumir","rootUri":"file:///home/zhanghua/文档/repositories/git/github.com/aumir"}

EXPECTED RESULT
zuban starts successfully.

SOFTWARE/OS VERSIONS
Windows: N/A
macOS: N/A
(available in the Info Center app, or by running `kinfo` in a terminal window)
Linux/KDE Plasma: 
KDE Plasma Version: 6.4.5
KDE Frameworks Version: 6.19.0
Qt Version: 6.10.0

ADDITIONAL INFORMATION
You can use this Kate user LSP configuration to setup zuban:
    {
        "python": {
                "command": ["zuban", "server"],
                "rootIndicationFilePatterns": ["setup.py", "pyproject.toml", "poetry.lock", "pdm.lock" , "uv.lock"],
                "url": "https://zubanls.com/",
                "highlightingModeRegex": "^Python$"
          }
    }

If I move my project to a path without any non-ascii characters, like `/home/zhanghua/aumir`, the server starts successfully.

See also: https://github.com/zubanls/zuban/issues/104
Comment 1 Bug Janitor Service 2025-10-21 13:48:47 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kate/-/merge_requests/1924
Comment 2 Christoph Cullmann 2025-10-23 16:42:09 UTC
Git commit 473337e0c02468dbb001c9280322b3242ee40db6 by Christoph Cullmann.
Committed on 23/10/2025 at 12:57.
Pushed by cullmann into branch 'master'.

encode the rootUri properly

in addition, use ::fromUtf8, that copies, the QLatin1String requires life time
of the array

it will work here, but I don't think it hurts to be safe

M  +2    -2    addons/lspclient/lspclientserver.cpp

https://invent.kde.org/utilities/kate/-/commit/473337e0c02468dbb001c9280322b3242ee40db6