lurch icon indicating copy to clipboard operation
lurch copied to clipboard

Remove line feeds from Base64 encoded data

Open sualko opened this issue 7 years ago • 3 comments

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.

sualko avatar Sep 06 '18 12:09 sualko

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.

gkdr avatar Aug 27 '19 18:08 gkdr

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.

sualko avatar Aug 28 '19 06:08 sualko

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.

gkdr avatar Aug 28 '19 09:08 gkdr