Constraints on high-order gravitational theories from weak cosmic censorship