The modern solution to this problem is to use different types for semantically distinct categories, even if the in-memory representation is effectively identical. Noticing that you’re mixing HTML-safe and HTML-unsafe strings is exactly the sort of thing the compiler should be able to help you with.