Mel Gibson took some “creative license” in his movie, including making the unfortunate connection you mention here.
John’s gospel recounts a story of a woman, unnamed, who is caught in the act of adultery (Jn 7:53-8:11). As she is about to be stoned, Jesus says “Let anyone among you who is without sin be the first to throw a stone at her.” There is no mention of the woman’s identity, and certainly no evidence to suggest any connection with Mary Magdalene. For some reason, some Christians like Mel Gibson have repeatedly marred Mary Magdalene’s reputation by making this unfair and biblically unwarranted connection.
Contrary to being identified as an adulterer or otherwise sexual sinner, the portrait of Mary Magdalene in the gospels is a supremely positive one. Never is there any mention of her sinfulness. In fact, the only biographical detail we have of her is a mention by Mark (Mk 16:9) and Luke (Lk 8:2) that Jesus cast seven demons out of her. Otherwise, she is given prime importance as a witness to the crucifixion, her presence at the empty tomb, and then meeting the risen Jesus. Her witness at these events surpasses that of even Peter who was said to have deserted Jesus at his Passion. In John’s gospel, especially, Mary Magdalene is upheld as an apostle in the most positive sense when Jesus appears to her first after his resurrection and missions her to proclaim the resurrection to his other disciples. (Jn 20:11-18).