Base64 wierdness

What’s the cleanest way to normalize Base64 content before decoding it in Zenphi?
Sometimes the Base64 comes from Gmail/API responses with line breaks, URL-safe characters (- and _), extra quotes, or missing padding.
Curious how others are handling this reliably before decoding or passing it to downstream actions.