Fix crasher in link handler

Fixes crashes on links like these:
[[constructor]]
[[constructor:foo]]

Also adds a test for these cases.

Change-Id: I2688666a03c00ef8eb2cb8fac653803d5756d23a