20 Commits

Author SHA1 Message Date
InvalidUsernameException
9d81c71aef Do not mis-parse certain wide-character emojis as integer
When calling ch_to_digit() with a UTF-16 or UTF-32 code unit, it simply
truncates away any data stored in the non-low byte(s) of the code unit.
It then uses a lookup table to determine whether the low byte
corresponds to an ASCII digit. This is incorrect because as soon as any
bit outside the low byte is set, the number will never correspond to a
ASCII digit anymore.

To fix this, we produce a mask that is all zeroes if any bit outside the
low byte is set in the code unit, all ones otherwise. Anding this mask
with the original code unit forces the table lookup to return the
sentinel value from the zero-index if any high bit was set and causes
the code unit not to be parsed as integer.

This bug was discovered when loading Mastodon posts inside the Ladybird
browser where some of Mastodon's JavaScript would trigger the code path
that erroneously parsed the emoji as integer. It had the visible effect
that some digits inside the posts would get rendered as one of the
emojis that parsed to that digit. For more details see this issue:
https://github.com/LadybirdBrowser/ladybird/issues/6205

The emojis in the test case are simply all the emojis used on Mastodon
that caused the bug. They can be found here:
06803422da/app/javascript/mastodon/features/emoji/emoji_map.json
2025-09-15 23:12:28 +02:00
Anders Dalvander
1a15c66fb9 harmonize files to use "east const"
manually checked modified files for errors, but not committing .clang-format due to the following warning:
>>> Setting `QualifierAlignment` to something other than `Leave`, COULD lead to incorrect code formatting due to incorrect decisions made due to clang-formats lack of complete semantic information. As such extra care should be taken to review code changes made by the use of this option.
2024-11-23 09:46:18 +01:00
Daniel Lemire
5ad6aae0b1 lint 2024-08-14 09:57:47 -04:00
Daniel Lemire
797e3e0bc2 more fixes 2024-01-28 16:01:46 -05:00
Daniel Lemire
7977ec6054 fix 2024-01-28 11:11:19 -05:00
Daniel Lemire
5334e2ba94 fix 2024-01-28 10:55:02 -05:00
Daniel Lemire
1d97749791 Verify and fix issue 235 2024-01-28 10:47:21 -05:00
TheRandomGuy146275
26a5b2eb16 Added test case for ignoring leading zeros for all bases
- added: fix incorrect base for leading zeros test

---------

Co-authored-by: Marvin <marvin.wu@mail.utoronto.ca>
Co-authored-by: Maya Warrier <34803055+mayawarrier@users.noreply.github.com>
2023-12-13 17:22:51 -05:00
Maya Warrier
30b3165520 Fix fast_int test Werrors 2023-12-12 22:45:14 -05:00
Maya Warrier
01e8c50a33 Fix bugs in tests/fast_int.cpp 2023-12-12 22:35:34 -05:00
Maya Warrier
5fcc62a6f5 Merge contributed tests 2023-12-12 22:03:33 -05:00
Marvin
ebc15bec51 Added test case for numbers within range after converted from base 2023-12-12 20:20:05 -05:00
Marvin
0711006266 Fixed messages 2023-12-12 19:23:43 -05:00
Marvin
681eb1ea38 More details to basic test error for debugging 2023-12-12 19:18:07 -05:00
Marvin
5fda2cc240 Debugging results 2023-12-12 19:07:51 -05:00
TheRandomGuy146275
e4702e039f Fixing cmake errrors 2023-12-12 17:58:32 -05:00
Marvin
20c9375c5e Added new test cases for out of range errors that cover 8,16,32,64 bits, out of range errors for all bases (64 bit only), and fixed some test cases 2023-12-12 13:59:18 -05:00
Marvin
e60b47455b Added test cases that coverunsigned, out or range errors, char pointers, invalid bases, and out of range bases 2023-12-11 18:17:33 -05:00
Marvin
2fb59699db Added more test cases that checks for correct errors, base 2, octal, and hex 2023-12-11 01:22:48 -05:00
Marvin
a91521f5a0 Added basic tests for fast_int in fast_int.cpp 2023-12-10 23:40:27 -05:00