The history of “Rapunzel” as a story is actually quite convoluted. Although the world is generally the most familiar with the version published by the Brothers Grimm in their 1812 collection Children’s and Household Tales, author and editor Terri Windling (who is wonderful, and you should absolutely read her stuff) traced it back much farther in her essay “Rapunzel, Rapunzel, Let Down Your Hair”: The Grimms took it from Friedrich Schulz’s version, which was published in 1790; Schulz had taken his version from the 1698 French tale “Persinette” by Charlotte-Rose de Caumont de La Force; and she had taken it from “Petrosinella,” a 1634 Italian story by Giambattista Basile.
In Basile’s version, the pregnant woman with the craving for greens (who appears to be a single mother — there’s no mention of a father in the picture) climbs into the forbidden garden herself, instead of making her husband do it; what’s more, the garden is an ogre’s, not a witch’s, and the woman craves parsley, rather than the type of lettuce known as rapunzel. The ogre catches her just as the witch does the husband in the Grimms’ story, though, and makes the same deal with her: She can have the greens if she gives the ogre the child. The woman agrees.
She names her daughter Petrosinella — a play on the word for “parsley” in the Neopolitan dialect — but interestingly, the ogre doesn’t claim the girl immediately. She’s seven when, passing the ogre’s house, the ogre tells her to remind her mother of her promise; she does so, and the woman, terrified, says, “Tell that woman my answer is: ‘Take her!’” So the ogre snatches up Petrosinella and hides her away in a tower with no doors and only one window.
From there, the story develops the same way as always — a prince finds her, he climbs up her hair, they have sex — but then it turns into more of an adventure than a tragic romance: Petrosinella tells the prince to bring a rope with him the next time he comes; then she drug the ogre, steals three magical acorns from her, and escapes. When the ogre awakens and chases after them, Petrosinella throws down the acorns one by one, which turn into a fierce dog (the ogre stops it by throwing it a crust of bread), a lion (dressed as a donkey, the ogre charges it down), and a wolf. The wolf eats the ogre, and the prince and Petrosinella get away scott-free. They marry and live happily ever after.
It’s possible that the heroine in this tale might be inspired by Saint Barbara, a Christian Greek Saint and martyr from around the third century. According to the lore, her father, a pagan, had locked her up in a tower to prevent the outside world from getting to her; however, unbeknownst to him, she had become a Christian, and so rejected the non-Christian marriages he arranged for her. Eventually he found out she was a Christian and tried to kill her, but her prayers literally opened a wall in the tower through which she escaped. She was eventually caught, tortured, and killed, however — but she maintained her faith the entire time. Ergo: Saint Barbara.
However, there’s some doubt about whether Barbara actually existed, so it’s not totally clear whether or not we can really consider this a “historic” basis for the “Rapunzel” tale.