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

new line at the end of provisioning URI results in invalid QR code #24

Closed
josefschabasser opened this issue Nov 6, 2019 · 5 comments
Closed

Comments

@josefschabasser
Copy link

josefschabasser commented Nov 6, 2019

Hello!

If I run bna show-url then the URL is missing : between the serial number and the ?:

$ bna show-url
otpauth://totp/Blizzard:EU123412341234?secret=ASFAS75ASDF75889G9AD7S69AS7697AS&issuer=Blizzard&digits=8

This URL results in an invalid QR code if generated via qrencode. The URL in the readme is correct, though.

Best Regards
Josef

PS: the readme is incorrect about the QR code genration. The readme still shows bna --otpauth-url which should be changed to bna show-url.

@josefschabasser
Copy link
Author

josefschabasser commented Nov 6, 2019

Workaround:

bna show-url | awk -v ORS= '{gsub(/\?/,":?");}1' | qrencode -t UTF8

or

bna show-url | sed -r 's/[?]+/:?/g' | tr -d "\n" | qrencode -t UTF8

jleclanche added a commit that referenced this issue Nov 11, 2019
@jleclanche
Copy link
Owner

I use the PyOTP library to generate that URL, could you report the issue there?

I fixed the readme.

@josefschabasser
Copy link
Author

josefschabasser commented Nov 15, 2019

I found the real issue. I couldn't reproduce it with pyotp on my own, but I found something different. The provisioning URI is working and correct, but python-bna is always adding a new line at the end. This is messing up the resulting QR code.

python-bna:

$ bna show-url | qrencode -t PNG -o otpauth.png
$ zbarimg --xml otpauth.png
<barcodes xmlns='http://zbar.sourceforge.net/2008/barcode'>
<source href='otpauth.png'>
<index num='0'>
<symbol type='QR-Code' quality='1'><data><![CDATA[otpauth://totp/Blizzard:EU123412341234?secret=ASFAS75ASDF75889G9AD7S69AS7697AS&issuer=Blizzard&digits=8
]]></data></symbol>
</index>
</source>
</barcodes>
scanned 1 barcode symbols from 1 images

python-bna with newline trimmed:

$ bna show-url | tr -d "\n" | qrencode -t PNG -o otpauth.png
$ zbarimg --xml otpauth.png
<barcodes xmlns='http://zbar.sourceforge.net/2008/barcode'>
<source href='otpauth.png'>
<index num='0'>
<symbol type='QR-Code' quality='1'><data><![CDATA[otpauth://totp/Blizzard:EU123412341234?secret=ASFAS75ASDF75889G9AD7S69AS7697AS&issuer=Blizzard&digits=8]]></data></symbol>
</index>
</source>
</barcodes>
scanned 1 barcode symbols from 1 images

@josefschabasser josefschabasser changed the title URL is missing ':' new line at the end of provisioning URI results in invalid QR code Nov 15, 2019
@jleclanche
Copy link
Owner

Fixed thanks!

@josefschabasser
Copy link
Author

I'm glad I could help! Thanks for fixing it!

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