Fix escaping to have the same behavior on all versions of Ruby