News for hackers. Stuff that matters.
Re:Trust in Firefox and Mozilla Is Gone – Let's Talk Alterna... by hcs on Sunday March 02, 2025 @03:58PM (#43234999)
> a str with invalid UTF-8 may cause UB, it's not unsafe to handle a str and they sure aren't going to put checks everywhere for it

Any way I know of for making a str from bytes is checked or unsafe, even slices (by byte indexes) are checked (panic). Is there a current example that hasn't been fixed at the language level where this invariant can be broken without unsafe?

Re:Trust in Firefox and Mozilla Is Gone – Let's Talk Alterna... by jpc0 on Monday March 03, 2025 @06:37AM (#43240753)
It's not about me parsing or creating a str. It's about the 100 dependencies every rust project has which might hand me a str that wasn't parsed safely.

I can avoid UB in my own C++ code too, the fact that the language has UB is a reason I even look at other options from time to time. To find UB in such a fundamental part of safe Rust was truly a surpise to me.

It feels like they could have very easily just made it a byte slice and said it's up yo you to validate, instead they decided it has to be valid UTF-8 or it's UB.