Fix a bug introduced by Hallvord's fix of my security bug. ^_^

(also factor out a method to deal with pre text)