JAKARTA, Indonesia — The professor sang an old anti-army song at a rally outside the state palace in central Jakarta, Indonesia’s capital. After a video of his performance appeared online, the police arrested him this month for insulting a state institution.

A week earlier, a housewife in Surabaya was sentenced to 10 months in jail over four WhatsApp messages that a local company found insulting. She denied even sending the messages, which were in Javanese, a language she does not speak.

Both the professor, Robertus Robet, and the housewife, Saidah Saleh Syamlan, were charged under Indonesia’s sweeping online criminal defamation law, which allows anyone to file a complaint and carries a sentence of up to four years in prison.

Human rights advocates call the law overly broad and say it is used by government officials and influential people to stifle free expression.