Mantis - Quercus
|
|||||
Viewing Issue Advanced Details | |||||
|
|||||
ID: | Category: | Severity: | Reproducibility: | Date Submitted: | Last Update: |
2271 | minor | always | 12-21-07 07:25 | 02-05-08 12:39 | |
|
|||||
Reporter: | jang | Platform: | |||
Assigned To: | nam | OS: | |||
Priority: | normal | OS Version: | |||
Status: | closed | Product Version: | 3.1.3 | ||
Product Build: | Resolution: | fixed | |||
Projection: | none | ||||
ETA: | none | Fixed in Version: | 3.1.5 | ||
|
|||||
Summary: | 0002271: thinko in base_convert: doesn't always work for large bases | ||||
Description: |
There's a bug in MathModule#base_convert - two, actually. The first is the conversion of the input value to a long result: if ('0' <= ch && ch <= '9') value = ch - '0'; else if ('a' <= ch && ch <= 'z') value = ch - 'a' + 10; else if ('A' <= ch && ch <= 'Z') value = ch - 'a' + 10; Pretty sure that last line should be, er, value = ch - 'A' + 26; (which 'a' - 10 doesn't evaluate to). On output, something similar: if (d < 10) sb.append((char) (d + '0')); else sb.append((char) (d - 10 + 'a')); is also erroneous. Additional information is a sample piece of code that demonstrates this: it'll spew out nonprintable characters occasionally. Caught this whilst hacking on Elgg to make it run under quercus; as it is, the piece of Elgg code that does this is pretty broken too :-/ but figured you'd probably want the fix anyway. Cheers, jan |
||||
Steps To Reproduce: | |||||
Additional Information: |
<?php $s = md5(time() . "123"); echo $s; echo "\n"; echo base_convert($s, 16, 36); ?> |
||||
Relationships | |||||
Attached Files: |
Notes | |||||
|
|||||
|
|