In addition to protecting yourself, you can be a good ally. Maeril made this great guide to what to if you are witnessing harassment:

maeril-what-to-do-if-you-are-witnessing-harassment

As she notes:

  1. Do not, in any way, interact with the attacker. You must absolutely ignore them and focus entirely on the person being attacked!
  2. Please make sure to always respect the wishes of the person you’re helping: whether they want you to leave quickly afterwards, or not! If you’re in a hurry escort them to a place where someone else can take over – call one of their friends, or one of yours, or if they want to, the police. It all depends on how they feel!