taint.txt 700 B

123456789101112131415161718192021
  1. Taint mode
  2. ==========
  3. The Nim compiler and most parts of the standard library support
  4. a taint mode. Input strings are declared with the `TaintedString`:idx:
  5. string type declared in the ``system`` module.
  6. If the taint mode is turned on (via the ``--taintMode:on`` command line
  7. option) it is a distinct string type which helps to detect input
  8. validation errors:
  9. .. code-block:: nim
  10. echo "your name: "
  11. var name: TaintedString = stdin.readline
  12. # it is safe here to output the name without any input validation, so
  13. # we simply convert `name` to string to make the compiler happy:
  14. echo "hi, ", name.string
  15. If the taint mode is turned off, ``TaintedString`` is simply an alias for
  16. ``string``.