Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't send a non UTF-8 characters over the bus #977

Open
yassinebenarbia opened this issue Sep 7, 2024 · 3 comments · May be fixed by #1010
Open

Can't send a non UTF-8 characters over the bus #977

yassinebenarbia opened this issue Sep 7, 2024 · 3 comments · May be fixed by #1010

Comments

@yassinebenarbia
Copy link

I was trying to send a path (PathBuf) through a (z/d)bus proxy to (z/d)bus server, but I got this error by trying to send a path with a non UTF-8 character

called `Result::unwrap()` on an `Err` value: Variant(Message("path contains invalid UTF-8 characters"))

So my question is:
Is it possible to send this exact path with no modification over it's encoding, or encoding is forced? and if so, is there a workaround?

Note:

  • Although I can have a work around by converting it to a loosy string, but I can't seem to be able to convert it back to the original encoded format, which what I need to access the file.
  • For reference, this is the non UTF-8 part of the path "\xC9vora", and this the loosly encoded one "�vora".
@zeenix
Copy link
Contributor

zeenix commented Sep 7, 2024

This is a known issue but:

  1. The decision to encode Path and PathBuf as UTF-8 strings come from serde, which is why we declare it as such too. It really should be encoded as byte slice (ay in D-Bus terms). I think the solution would be to provide our own wrapper types that do the right thing. I've been hoping @bilelmoussaoui will do that, as he seems to have the impl already in his code (although I think I'd prefer simple wrapper types for both Path and PathBuf) but he's been super busy. Perhaps you could contribute this?
  2. The error you're getting is gone in main (4af9d91) so at least it's not going to be as big an issue anymore. The bus (broker) might not like embedded null bytes though and disconnect you for violating the spec..

@yassinebenarbia
Copy link
Author

I'll look through that in another time I guess.

@yassinebenarbia yassinebenarbia linked a pull request Sep 20, 2024 that will close this issue
@yassinebenarbia
Copy link
Author

yassinebenarbia commented Sep 20, 2024

  1. Perhaps you could contribute this?

I've made a PR #1010 for this issue, if you can, please consider reviewing it.

yassinebenarbia added a commit to yassinebenarbia/zbus that referenced this issue Sep 24, 2024
Add FilePath type as a thin wrapper around Path/Cow<Path>

- Implement FilePath as a wrapper around Path/Cow<Path>
- Derive Type, Debug, Default, PartialEq, and Eq traits
- Implement from/to_bytes methods for serialization
- Provide examples of usage and comparison with Path/PathBuf

Fixes dbus2#977.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants