Oniguruma does not consistently perform this validation itself (at least on older versions), so make sure we check pattern encoding validity on the PHP side.
Should fix bug #77381, bug #77382, bug #77385, bug #77394.