It seems like it's probably safe to just do this on one side of the connection. You're now doing this on the client side. Or is there a code path I haven't noticed yet that could still pass an unsanitized port across?