Actually this was fixed already by https://github.com/xwiki/xwiki-platform/commit/e29d27938b9db464737fb91a091e95f927b97092, but not on older branches. Cherry-picking it.