Comment 13 for bug 340106

Revision history for this message
In , Thiago Macieira (thiago-kde) wrote :

(In reply to Harald Sitter from comment #7)
> Thanks.
>
> With that in mind we cannot really support spaces while also following the
> smb URI format [1]. I suppose we'll just have to deviate a bit iff the
> workgroup name contains a space by using a variant of the notation that
> stuffs the workgroup into the userinfo `smb://work group;@/` and then
> translate that back to an smb URI for libsmbclient again. Means the urls
> wont be portable but at least navigation within our tech works.
>
> [1] https://www.iana.org/assignments/uri-schemes/prov/smb

You may need the user info for the actual user name that is being used to search that work group. I would recommend using the path or query component instead:

smb://userwg;user:password@/browsed_workgroup
smb://userwg;user:password@/?=search=browsed_workgroup

This searches the workgroup named "browsed_workgroup" with the user "userwg\user".

The query has the added benefit a server inside the workgroup is a proper sub-URL:

smb://userwg;user:password@server/share/folder/file.txt?search=browsed_workgroup

That is,

  QUrl wg("smb://user@/?search=WG");
  QUrl relative("/share/folder/file.txt");
  qDebug() << wg.resolved(relative); // "smb://user@/share/folder/file.txt?search=WG"