One function

RstrBase in leapfrogonline/rstr

The author described this change as Fixes bug: 'include' can make the string too long.. It counts as a record because the check below fails on the code as it stood at 9feb12beb and passes on 305f1ae57, with nothing else changed between the two runs.

Fix saved2020-07-04
Sharing licenceBSD-3-Clause · LICENSE.txt
Change size+3 0

What the code was meant to do, written into the code itself as a docstring

Create random strings from a variety of alphabets. The alphabets for printable(), uppercase(), lowercase(), digits(), and punctuation() are equivalent to the constants by those same names in the standard library string module. nondigits() uses an alphabet of string.letters + string.punctuation nonletters() uses an alphabet of string.digits + string.punctuation nonwhitespace() uses an alphabet of string.printable.strip() normal() uses an alphabet of string.letters + string.digits + ' ' (the space character) postalsafe() is based on USPS Publication 28 - Postal Addressing Standards: http://pe.usps.com/text/pub28/pub28c2.html The characters allowed in postal addresses are letters and digits, periods, slashes, the pound sign, and the hyphen. urlsafe() uses an alphabet of unreserved characters safe for use in URLs. From section 2.3 of RFC 3986: "Characters that are allowed in a URI but do not have a reserved purpose are called unreserved. These include uppercase and lowercase letters, decimal digits, hyphen, period, underscore, and tilde. domainsafe() uses an alphabet of characters allowed in hostnames, and consequently, in internet domains: letters, digits, and the hyphen.

The change

8181
8282 if end_range:
8383 k = self._random.randint(start_range, end_range)
84+ # Make sure we don't generate too long a string
85+ # when adding 'include' to it:
86+ k = k - len(include)
8487
8588 result = self.sample_wr(popul, k) + list(include)
8689 self._random.shuffle(result)

The check that tells the two apart

failpass·rstr/tests/test_rstr.py::TestRstr::test_include_specific_length

Check file rstr/tests/test_rstr.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it9feb12bebe09df6b9901f1219f13c0eaa5796569
Broken version dated2020-07-04
Modulerstr.rstr_base
Units changedRstrBase
Fingerprint104f0184a449f4ed
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in leapfrogonline/rstr