Thanks Leighton, and welcome to Tikiwiki Community!
Could you please post this as a bug and as the patch to fix this bug at the dev.tw.o tracker preapred for this?:
(submit a bug report, ...)
This way, you can provide more information that is needed: version, features affected, etc. And someone can review it, find it when filtering for features, etc.
Thanks! and thanks for contributing your fix.
(I don't have time now to test it, but I would in a few months, if nobody else does, and I can find your fix later on...)