The fix suggested in the top of this thread should work fine.
That security vulnerability is tiny compared to the biggie that UBB5.47e fixed. Upgrade to 5.47e if at all possible.
Whether you upgrade to 5.47e or not, you should install my CodeFilter mod. It closes a nasty security hole not fixed by 5.47e:
https://www.ubbdev.com/ubbcgi/ultimatebb.cgi?ubb=get_topic&f=7&t=000434