Skip to content

[omemo] Fix fingerprint window for qrcode v. < 6.0

Malte L requested to merge maltel/gajim-plugins:fix-qrcode into master

The recent commit eff7d037 adds that - with the qrcode python library being installed - a qrcode of the users fingerprint is available in the omemo fingerprint window. However, if the user has qrcode installed at a version older than 6.0, then an exception is thrown that makes the entire fingerprint window not being able to be shown. This change should fix this.

Note that I have not tested this (yet?) with versions of qrcode 6.0 and newer, so someone should probably test it works before this is merged.

Details on the problem with the older versions of qrcode: Commit a85b15c of python-qrcode switched the meaning of fill_color and back_color: before then, what was externally called fill_color was used for back_color internally and vice versa. The omemo plugin tries to pass 'transparent' as back_color. As 'transparent' is not a valid color name in PIL, qrcode has some code that handles values of 'transparent' for the internal back_color, but not for the internal fill_color, which hence leads to an invalid color name being used with qrcode versions 5.3 and earlier.

The solution implemented here tests whether the qrcode version is older than 6.0, and, if yes, switches the two colors so that everything should work as expected even with the older versions.

Merge request reports