Topological protection of photonic mid-gap cavity modes