codebude / QRCoder

A pure C# Open Source QR Code implementation
MIT License
4.59k stars 1.09k forks source link

QR Code unable to be scanned properly on iOS #375

Closed hmireault-devo closed 6 months ago

hmireault-devo commented 2 years ago

Type of issue

[X] Bug

Expected Behavior

QR Codes generated with the same payload on version 1.4.2 and version 1.4.3 should result in the same image, and should be properly readable no matter the platform.

Current Behavior

On QRCoder 1.4.3, codes generated with a certain payload are not able to be read properly on Microsoft Authenticator on iOS. On Android, there are no problems reading the QR code. Codes generated on version 1.4.2 of the library work properly no matter the platform.

Possible Solution

I suspect the space character in the issuer or label is causing the issue, and it may be handled differently in version 1.4.3 compared to the previous version. When trying to reproduce the issue with an issuer and label without spaces, the issue does not occur.

Steps to Reproduce

Sample code to generate the faulty QR code image:

QRCodeGenerator qrcodeGenerator = new QRCodeGenerator();
PayloadGenerator.OneTimePassword generator = new PayloadGenerator.OneTimePassword()
{
    Secret = "M54WC6TFJB2TQSCFGA2WOWLFIJCWOWSV",
    Issuer = "My Test Issuer",
    Label = "My Test Label"
};

QRCodeData qrcodeData = qrcodeGenerator.CreateQrCode(generator);
QRCode qrcode = new QRCode(qrcodeData);
this.pbQR.Image = qrcode.GetGraphic(5);

Generating the QR code image with version 1.4.2 will give the following: QRCoder - Test 1 4 2

Generating the QR code image with version 1.4.3 will give the following: QRCoder - Test 1 4 3

When using the Microsoft Authenticator app on iOS and scanning the first code, everything works. When using the Microsoft Authenticator app on iOS and scanning the second code, the error "Invalid URL or Barcode" is shown.

When using the Microsoft Authenticator app on Android, both codes work.

Your Environment

craigpeterson-GAS commented 2 years ago

The 1.4.3 example QR code above also generates an error when scanned with LastPass Authenticator.

The error message is: Device Pairing Failed Bad code: bad scheme (com.logmein.lpa.error / -5)

It works with Authy.

jimivey commented 2 years ago

We're experiencing the same problem, with similar code to the OP. All of our test devices worked fine with 1.4.2, but starting with 1.4.3 we're seeing issues with some authenticator apps (Microsoft and LastPass) on iOS devices.

codebude commented 6 months ago

Should be fixed with: https://github.com/codebude/QRCoder/pull/391 The PR will be part of QRCoder 1.5.0 which will be released within the next couple of days. Please re-open in case 1.5.0 still shows the same problem.