HSF: Defending against Jailbreak Attacks with Hidden State Filtering