Minor refactoring to simplify other changes.

Move adding the value to the build to a separate step, only fetch
the majorkey in one place.

This makes it easier to modify the value if needed.

Change-Id: I360ec3351f3dd4af285d463d58cade004a3c1099
Actually instantiate the templater in the test for this.

Change-Id: Iaff45e30427bf32653e0bac6a3d1d197a7285313
Introduce a helper for constructing the item under test.

This will make it possible to tweak it for all tests in a simple manner.

Change-Id: Ib328cecf4046dd0a19469e2bdbfc1d47f68ad624
Add a mechanism to escape tagged template blocks.

By adding a colon (:) to the start of the braced block, the block's
value is marked as 'safe', and doesn't need escaping. For the moment,
the escaping function doesn't actually do anything.

Change-Id: Ib09b84dd5ed4671ac8cc2b1f97116e7aaab92796
Add HTML escaping by default, label some fields as safe.

I believe this resolves the possible HTML injection issues raised by
Alex, covering both raw html and <input> fields. I've tried to only
mark safe those fields that are expected to contain html (and I think
these are all constructed from other templates too), so some fields
which may not need escaping will be covered anyway.

I've manually tested this by inputting the nasty input:
   "><script>alert('XSS!');</script><!--
into every field I could see, and this appears to cover us for web
output, though clearly nothing stops this getting into emails (etc.)
that we may emit elsewhere.

Change-Id: I8a65031228bd8917824ce4aedb3402332afca146
Add a helper for checking name validity.

For the most part, we don't care what the user's name is. However,
the first character is used to build their username so we need to
make sure that this is an alphabetic character.

Change-Id: I9539cab09eae4807b1d380a3becf1e7f0fe7a71b
Reject registrations of names that don't start with a letter.

Since we use the names to construct the username, and then check
whether that name (plus an incrementing number) exists, there's the
potential for the user to either mess with our LDAP (unlikely with
the two characters available) or just get LDAP to cause us to 500
at them. The latter is much more likely, and results in the regisrations
form becoming a bit dead, which this should resolve.

Change-Id: Icf3e259a13b97d83c966d60f26c77a99b3adeaa8