2 ms·
If you want even better escaping safety: use different types for safe vs unsafe strings. You should not ever be crossing the streams. So make it a compile-tim
by Groxx 4y ago
If you want even better escaping safety: use different types for safe vs unsafe strings.
You should not ever be crossing the streams. So make it a compile-time failure. And anywhere you truly do know better, you can just use a transformation func like `safe = iKnowWhatImDoingCompilerSTFU(unsafe)`
And keep in mind that "escaping" is not a binary. Something that works in an HTML node's body may not work in an attribute or a request header or a URL. This is the primary reason that most things suggest escaping at output time: you cannot safely escape something without knowing where it will be used.