Added robustness checks to JavaScript, Python, C++ code without changing functionality in normal operation.
This commit is contained in:
parent
8bdecc51a3
commit
1fb0283189
|
@ -348,7 +348,7 @@ void qrcodegen::QrCode::drawCodewords(const std::vector<uint8_t> &data) {
|
|||
bool upwards = ((right & 2) == 0) ^ (x < 6);
|
||||
int y = upwards ? size - 1 - vert : vert; // Actual y coordinate
|
||||
if (!isFunction.at(y).at(x) && i < data.size() * 8) {
|
||||
modules.at(y).at(x) = ((data[i >> 3] >> (7 - (i & 7))) & 1) != 0;
|
||||
modules.at(y).at(x) = ((data.at(i >> 3) >> (7 - (i & 7))) & 1) != 0;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,6 +86,8 @@ var qrcodegen = new function() {
|
|||
if (version < 1 || version > 40)
|
||||
throw "Version value out of range";
|
||||
} else if (initData instanceof qrcodegen.QrCode) {
|
||||
if (version != undefined || errCorLvl != undefined)
|
||||
throw "Values must be undefined";
|
||||
version = initData.version;
|
||||
errCorLvl = initData.errorCorrectionLevel;
|
||||
} else
|
||||
|
|
|
@ -158,6 +158,8 @@ class QrCode(object):
|
|||
if not isinstance(errcorlvl, QrCode.Ecc):
|
||||
raise TypeError("QrCode.Ecc expected")
|
||||
elif qrcode is not None and datacodewords is None:
|
||||
if version is not None or errcorlvl is not None:
|
||||
raise ValueError("Values must be None")
|
||||
version = qrcode._version
|
||||
errcorlvl = qrcode._errcorlvl
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue