Realistically, this function won't change. It's mostly designed as a "quick and dirty" approach to stripping BB code and being wrong in edge cases is acceptable. For example, note that it really just strips things that look like BB code and doesn't respect the rules of the plain tag. Removing unmatched tags would lead to false positives far more often than what it currently misses.
A more accurate BB code removal system is available through XenForo_BbCode_Formatter_BbCode_Strip, though at the cost of it likely being slower.