(Bigstock photo)

THE STORY of the spurned lover seeking revenge may make for a good movie — but in the real world, there is nothing entertaining about it. Too often, people put explicit images of former partners online to hurt and harass them, sometimes along with information that can lead to stalking and threats. Because not every state has a law barring the practice, many perpetrators go unpunished. A bill in the House of Representatives could help deter the behavior.

Rep. Jackie Speier (D-Calif.) has introduced legislation that would patch the holes in the federal system governing nonconsensual pornography, also known as revenge porn. The District and 34 states have laws criminalizing the publication of explicit images and videos without the subject’s consent. But because they vary in strength and because the Internet operates across state lines, a uniform federal rule would be helpful. Ms. Speier’s bill would provide one, and similar legislation could soon appear in the Senate.

Speech advocates say the bill is too broad and could sweep pornography that should be permissible into the category of the illegal. They also worry about a chilling effect on those who wish to post or re-post content that is clearly allowed, from snapshots of family and friends on topless beaches to photos in adult magazines. A narrower law cracking down only on originators of offending content and requiring an intent to harm the subject, they say, would be a better solution.

But bill supporters say the legislation is already narrow enough. Ms. Speier seeks to punish two types of players: those who knowingly post nonconsensual pornographic content and downstream distributors who knowingly solicit or share that content, often to make money. Limiting the scope to initial posters would let distributors act with impunity. Tightening the standard from the bill’s already-stringent “reckless disregard” rule would make it hard for victims to make a case in court.

As it is, the law takes care to shelter speech and privacy at the same time. It includes an exception for material gathered in a public setting without an expectation of privacy and for material that serves a public interest, which could include artistic, historical or news value. There’s always a danger of overzealous prosecution, but the law’s practical purpose would not be to block images of bathing babies or breastfeeding mothers: It would be to protect women or men who would otherwise be subject to exploitation and harassment.

Any law that restricts free expression deserves scrutiny. As Ms. Speier’s bill moves forward, lawmakers will have the chance to debate whether it strikes the right balance. What is not up for debate, though, is the need for a national rule.