A person is to be punished with a just penalty who, at a public event or assembly, or in a published writing, or by otherwise using the means of social communication, utters blasphemy, or gravely harms public morals, or rails at or excites hatred of or contempt for religion or the Church.
Source: Code of Canon Law (Vatican.va)