Bug 11600 – to!BigInt(string) accepts non-numeric input

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2013-11-25T00:11:00Z
Last change time
2013-12-04T09:37:58Z
Keywords
pull
Assigned to
nobody
Creator
supernova2003dh

Comments

Comment #0 by supernova2003dh — 2013-11-25T00:11:13Z
The function to!BigInt(string) accepts non-numeric input like "avadakedavra" without throwing an exception. Expected result: An exception is thrown. Actual result: No exception is thrown, and the BigInt is initialized. This violates the principle of least astonishment.
Comment #1 by hsteoh — 2013-11-27T18:25:10Z
Wow, this is bad. The BigInt implementation doesn't even check if the given string contains digits, it just *assumes* anything that isn't '_' is an ASCII digit, and simply subtracts '0' from it and treats the result as a decimal value.
Comment #2 by hsteoh — 2013-11-27T18:51:35Z
Comment #3 by supernova2003dh — 2013-11-30T12:28:14Z
Comment #4 by github-bugzilla — 2013-12-03T17:13:35Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/1945bcacf8aaac4ad17d0184181ef72ff9bdec12 Fix issue 11600: to!BigInt(string) should validate input. https://github.com/D-Programming-Language/phobos/commit/04c43ce00b5e0fff4742af9abe415dd028d24792 Merge pull request #1731 from quickfur/issue11600 Fix issue 11600: to!BigInt(string) should validate input.
Comment #5 by hsteoh — 2013-12-04T09:37:58Z
Confirmed fixed in git HEAD.