From Matt Poduska via bug 1957 (with minor changes):