Real Madrid have reached the Copa del Rey quarterfinals with a controversial 5-2 win at home to Celta Vigo after extra time.