Package 

Class Tainted

  • All Implemented Interfaces:
    com.planbase.taint.Taintable , java.io.Serializable , kotlin.Comparable

    
    public final class Tainted
     implements Comparable<Tainted>, Serializable, Taintable
                        

    An immutable, untrusted java.lang.String. This allows the type system to prevent XSS errors, double-encoding, and similar errors. This cannot implement HtmlUrlStringable, Htmlable, etc. because HtmlSequence.p() is overridden to take all of those types, and we need to specify how we want this tainted string encoded - there is no one right answer.

    Use the taint static factory methods to wrap all untrusted inputs. If the inputs can be null, use the taintNullable methods instead. Instead of using StringBuilder/StringBuffer with this, use TaintBuilder.

    toString is overridden to surround the wrapped string with ⛔ "No Entry" (road signs) which are always bold and easy to see everywhere. If you see this sign, it means you haven't encoded the data correctly for your output. It's a "make-wrong-look-wrong" thing (thank you, Joel Spolsky) https://www.joelonsoftware.com/2005/05/11/making-wrong-code-look-wrong/

    This is called Tainted because that's what it's called in other programming languages and the relevant Wikipedia article is titled, "taint checking." It's fairly short (7 letters) and can't be mistaken for anything else (Taint sounds like a verb to me).