Backport of TorLock regex fix from dproxy.