Massachusetts lawmakers approved legislation Thursday to crack down on those who secretly take photographs of "the sexual or other intimate parts" of women or children in public.

Approval of the bill, which also would apply to male victims, came a day after the state's highest court ruled that a man who took cell phone photos up the skirts of female passengers riding the Boston subway didn't violate state law.

Top lawmakers said the bill will send a clear message to those who take so-called "upskirt" photos.

"It is sexual harassment. It's an assault on another person whether it's a child or an adult," Senate President Therese Murray said moments after the Senate unanimously approved the bill.

The legislation says anyone who "photographs, videotapes or electronically surveils" another person's sexual or intimate parts without that person's consent would face a misdemeanor charge and a maximum penalty of two-and-a-half years in jail and a $5,000 fine.

The crime becomes a felony with a maximum penalty of five years in prison and a $10,000 fine for photographs or recordings of a child under 18. Wednesday's court decision overruled a lower court that had upheld charges against Michael Robertson, who was arrested in 2010 by transit police who set up a sting after getting reports that he was using his cell phone to take photos and video up the skirts and dresses of female riders.

The state's existing Peeping Tom law "does not apply to photographing (or videotaping or electronically surveilling) persons who are fully clothed and, in particular, does not reach the type of upskirting that the defendant is charged with," the court said.