Sunan an-Nasa'i, Book 27, Hadith 47 (Nasa'i 3441)

It was narrated from Abu Hurairah that the Prophet said:

"Allah, the Most High, has forgiven my Ummah for whatever enters the mind, so long as it is not spoken of or put into action."