Add obfuscation option for the TextInput component and use it to implement a streamer mode option to hide your IP addresses#2029
Conversation
|
Idk if it's just me but it looks a bit... Squished horizontally. |
That's how the |
|
Perhaps we should consider fixing the font at some point, but if that's all it is, that could be a separate issue I'd guess |
7f18a12 to
045b992
Compare
TIL about asterisk variants... there is a thing called a heavy asterisk: ✱ (https://en.wikipedia.org/wiki/Asterisk#Encodings) |
045b992 to
9392bb6
Compare
IntegratedQuantum
left a comment
There was a problem hiding this comment.
Every time I look at it to review, I come to the conclusion that it is doing too much.
Please explain why you decided against just obfuscating it during render. If "avoiding allocations" is the only reason (and I think all the other problems mentioned are easily fixable), then I'd say it isn't a particularly good one, since the stackAllocator is cheap, and if you want to optimize text rendering, then a rare case in a rare component is a pretty bad starting point. On the other hand the 80 extra lines you need here are possibly more error prone and introduce edge cases (→what happens if the user adds more than 512 characters).
|
I wasn't aiming to optimize text rendering; all I wanted was to get the obfuscation working and ensure it handled UTF-8 correctly. But yes, I suppose at the time it seemed to me that performing obfuscation every single frame wouldn't be a good idea. Regarding memory, I agree with the buffer size issue, but in practice, the only purpose of obfuscation is to hide an IP address - and perhaps a password or username in the future, these will never exceed 512 bytes in length. I'm not saying the problem shouldn't be fixed, I'm just pointing out that this solution isn't that bad. So, I don't see any problem to implement obfuscation in |
Said the programmer 2 seconds before the text reached 513 bytes in length. Trust me, @codemob-dev will paste whole Lord of the rings subtitles in Chinese into it just to mess with you. |
Can confirm. |
Then please make it so. |
d597536 to
92096da
Compare
Done. And the stack allocator is used to allocate a temporary string with obfuscated chars. I also added a |
92096da to
4c6e048
Compare
4c6e048 to
73cf4a8
Compare
73cf4a8 to
a643fec
Compare
| self.ensureCursorVisibility(); | ||
| } | ||
|
|
||
| pub fn obfuscateString(string: []const u8, allocator: NeverFailingAllocator) []const u8 { |
There was a problem hiding this comment.
I would suggest to move this to utils, it certainly doesn't belong buried deeply in a random gui component.
Also allocators should (except self) generally be the first parameter.
There was a problem hiding this comment.
I thought about this too, I just couldn't find a suitable place in the utils
There was a problem hiding this comment.
Just put it at the end of the file then.
b609d60 to
e8ba77c
Compare






Adds the ability to hide the input text. Usage via the
.obfuscate()and.deobfuscate()methods. To ensure uniform and consistent use of the same obfuscation character across other parts of the code, the global membersTextInput.obfuscationCharandTextInput.obfuscatedStringBufferare public.This will be very useful for #1929. The implementation proposed in #1933 is broken, does not support Utf8, and constantly uses memory allocation to create a string of filler characters, which is precisely why I am proposing this implementation.
fixes #1929