El Dimarts, 19 de maig de 2015, a les 11:17:09, Daniel Vrátil va escriure: > On Monday, May 18, 2015 07:32:54 PM Robby Stephenson wrote: > > Hi, > > > > In the process of porting Tellico to KF5, one of my unit tests that > > depends on KCodecs::base64Encode() started to fail. After poking at it a > > little bit, my impression is that KF5::KCodecs is including a newline at > > the end of the byte string, where the kdelibs4 version didn't. > > > > But it's late, and I'm not seeing completely straight either, so I > > wanted to ask the mailing list. I must be doing something wrong... > > > > Using the simple test-case in the class documentation: > > QByteArray input = "Aladdin:open sesame"; > > QByteArray result = KCodecs::base64Encode(input); > > qDebug() << "Result: " << result; > > > > With kdelibs4, I get this: > > > > Result: "QWxhZGRpbjpvcGVuIHNlc2FtZQ==" > > > > which I expect. > > > > But with KF5::KCodecs, I get this: > > > > Result: "QWxhZGRpbjpvcGVuIHNlc2FtZQ== > > " > > > > which obviously includes a newline. > > > > Am I missing something? Looking at the KCodecs code, the insertLFs > > variable is completely ignored, though it wouldn't matter in my test > > case anyway since the string is less than 76 characters. And it's not a > > qDebug problem, I don't think. > > > > Any help? I'm feeling rather silly... > > You are correct - when the encoding finishes and the quartet is finished a > (CR)LF is appended to the end in Base64Encoder::generic_finish(). > > In KF5 the base64 code was brought from KMime (email parsing library from > kdepimlibs), where appending a newline after encoded base64 data makes > sense. I don't know if we can just change the behaviour like that since it > has already been release, but for sure we could add a new argument to > KCodecs::base64Encode() to skip the trailing newline.
Honestly it totally feels like a bug. Does lxr.kde.org show anyone using this? Do we know anyone using it from the outside? If not i'd just fix it, put it in the CHANGELOG: with an obvious message and let it behave as one would expect. Cheers, Albert > > Dan > > > Thanks! > > Robby > > > > >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to > > >> unsubscribe > > >> << > >> > >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe > >> << >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<