Does your password have backslashes or other characters? It does work as you expect most of the time, but due to the nature of regex and sed it’s a little fragile. You’re the first person in a long while to complain {and you knew how to fix it).
If you can figure out a way to make it work, I’m sure a PR would be accepted (though I don’t make that decision).