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

Remove line feeds from Base64 encoded data #121

Open
sualko opened this issue Sep 6, 2018 · 3 comments
Open

Remove line feeds from Base64 encoded data #121

sualko opened this issue Sep 6, 2018 · 3 comments

Comments

@sualko
Copy link

sualko commented Sep 6, 2018

I discovered that lurch in version 0.6.7 adds newlines after a couple of characters to it's Base64 encoded data. This is probably a bug, according to RFC 4648:

Implementations MUST NOT add line feeds to base-encoded data unless the specification referring to this document explicitly directs base encoders to add line feeds after a specific number of characters.

Because in XEP-0384 I find no advice, regarding a max line length.

@gkdr
Copy link
Owner

gkdr commented Aug 27, 2019

Which data exactly? I didn't implement b64 myself and am generally using the glib function g_base64_encode(). I just checked and it doesn't have any options I might be misusing.

@sualko
Copy link
Author

sualko commented Aug 28, 2019

It's hard to remember after one year, but I think to every data (key, payload, signedPreKeySignature, ...). If you are using https://github.com/GNOME/glib/blob/e0e4968dca8ad737753c0d6f8034c6f08c5002e8/glib/gbase64.c#L261-L281 there should be no line breaks, because line_breaks is false.

@gkdr
Copy link
Owner

gkdr commented Aug 28, 2019

It's hard to remember after one year

I can imagine! Sorry, I got a bit overwhelmed with issues at the time and later falsely remembered that I was just waiting for more input on all of them until I had another look recently.

If you are using https://github.com/GNOME/glib/blob/e0e4968dca8ad737753c0d6f8034c6f08c5002e8/glib/gbase64.c#L261-L281 there should be no line breaks, because line_breaks is false.

I am (in the libomemo submodule), and that line has not changed for 12 years so I doubt it's a glib version issue either. I'm going to check whether I do anything weird with the resulting XML in this plugin itself - one thing that comes to mind is exporting a string and reimporting it because I didn't want to deal with libxml2 in libomemo and serializing was a quick and good enough solution so I can use mxml.
First I'll look at the raw XMPP from the debug log to see if I can find the line breaks though, never really noticed such a thing.

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

No branches or pull requests

2 participants