Most of them are safe. But everyone, not just breastfeeding mothers, needs to be careful about taking drugs such as Tums (calcium carbonate) with milk. Taking large amounts of calcium plus milk for an upset stomach can result in high levels of calcium in your blood and may lead to kidney stones and even kidney failure. I mention this because many mothers drink a lot of milk when breastfeeding because they think it helps make milk (which isn't true) or to prevent osteoporosis.
Proton pump inhibitors, such as omeprazole (Prilosec) and lansoprazole (Prevacid), are also popular drugs for treating heartburn. These drugs are almost immediately destroyed by stomach acid and are therefore covered with a protective layer that allows them to pass through the stomach and into the mother's body without being destroyed. However, the tiny amounts of these drugs that are passed through breast milk no longer have this protective coating and are immediately destroyed in the baby's stomach. Therefore, there is no concern about this type of drug.
Ranitidine (Zantac) is another sort of drug used for heartburn. Again, very little gets into the milk. It is used (overused actually) to treat “reflux” in babies and if we can give it to babies directly, we can give it to breastfeeding mothers. The baby will get much less in the milk than when given it directly.