papnkukn / qrcode-svg

A simple QR Code generator in pure JavaScript / node.js library
MIT License
451 stars 93 forks source link

What's with the obfuscated code? #26

Open viomck opened 2 years ago

viomck commented 2 years ago

https://github.com/papnkukn/qrcode-svg/blob/47d56ec28fcd0a3aabbb5f11a34167a02a80c54e/lib/qrcode.js#L88-L153

leMaik commented 2 years ago

I'm concerned about this too, as I couldn't figure out where this code comes from.

  1. The library this is based on also has the same obfuscated code
  2. The original library mentioned in the comment above that blob has non-obfuscated but slightly different content (even if it is similar in structure): https://github.com/kazuhikoarase/qrcode-generator/blob/master/js/qrcode.js
  3. This version from jquery-qrcode looks identical to the obfuscated code in this library but instead of QRCodeModel it uses QRCode.

Both libraries (2, 3) are missing the QRCodeLimitLength variable though.


Edit: I pretty-printed the obfuscated code with Prettier and compared the three versions. This version is nearly identical to the non-obfuscated version from [3] but with support for utf8 characters from [1]. Unlike this version, however, [3] can determine the type number automatically depending on the data length (ie. https://github.com/kazuhikoarase/qrcode-generator/pull/41 from [2]).

I'll create a repo with the diffs for transparency and submit a PR. Done: https://github.com/leMaik/qrcode-svg

viomck commented 2 years ago

Thank you @leMaik!