applying patch from alex gaynor and glyph

git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/branches/browserlikepolicy-secfix-7647@43124 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb