Before the 1970s, most rape victims who dared to take their cases to trial were forced to undergo humiliating and degrading experiences: The rapists’ attorneys would call up a series of witnesses to testify that the female victims were promiscuous, licentious, and immoral. The purpose of these exercises was to convince juries that the victims were actually whores, women who couldn’t say no to sex. It built on the era’s conventional wisdom about virtue—namely, that if an alleged rape victim wasn’t a virgin, she was a slut who was likely lying about her rape.

Today, almost every state has a “rape shield” law to keep this kind of odious testimony out of trial, including California. That’s why it’s so shocking to read KPCC’s investigation into a recent Los Angeles trial at which a judge permitted evidence of a 14-year-old girl’s sexual history. The girl, a student at an L.A. public school, had sued her school district for allowing her 28-year-old teacher to molest her, arguing that she was emotionally traumatized. (The teacher is now in prison.) In response, the school district’s lawyer, Keith Wyatt, first claimed that the student was sexually mature enough—at age 14—to engage in consensual sex with her teacher, introducing evidence that she had previously been sexually active. Wyatt then argued that the student was suing the school district only out of greed, telling the jury:

She wants to be paid for doing something that she knew was wrong, that she acknowledged was wrong, that she knew was from the beginning. … She doesn’t want therapy, she wants money. That’s what they are asking you for.

Wyatt also painted the student, grotesquely, as a vixen and seductress. In an interview, he told KPCC that “she lied to her mother so she could have sex with her teacher. … She went to a motel in which she engaged in voluntary consensual sex with her teacher. Why shouldn’t she be responsible for that?” (Wyatt later apologized, describing his comments as “ill-thought-out and poorly articulated.”) Ultimately, the jury ignored the consent question and decided the case on different grounds, holding that the school wasn’t liable because it wasn’t aware of the molestation.

How did this noxious nonsense wind up in a California courtroom? In short, a perfect storm of loopholes and technicalities. Most glaringly, California’s rape shield law only covers criminal cases, not civil ones—so if a victim sues her rapist, or her rapist’s alleged enablers, a defense attorney can unquestionably introduce evidence of her purported licentiousness at trial.

But perhaps even more alarmingly, Wyatt exploited a horrifying (and probably unintentional) inconsistency in California law. In criminal cases, the age of consent in California is 18. But in civil cases, the age of consent is debatable. That strange discrepancy is the result of a 2001 California Supreme Court ruling, in which the justices found that, under the state’s age of consent statute, “a minor may be capable of giving legal consent to sexual relations.” Accordingly, in California today, if a minor sues an adult for damages pertaining to molestation, her convicted molester can argue in court that his victim actually consented to sex. And he can trot out his victim’s previous sex partners to testify in his defense.

These two loopholes can, and should, be fixed by the California legislature immediately. No one—especially not teenage girls—should be deterred from filing a just lawsuit out of a fear that she’ll be slut-shamed in the public eye. Nor should a molester be permitted to smear his underage victim as a sexed-up siren who lured him into an erotic relationship. It’s already hard enough for rape victims to bring their accusers to court and win. They don’t need two more anachronistic and insulting hurdles to clear.