Allah Most High never mentions any such matter concerning a prophet in the Quran without accompanying it with repentance and seeking forgiveness. Thus, Adam and his wife said:
“Our Lord, we have wronged ourselves. If You do not forgive us and have mercy upon us, we will surely be among the losers.”
Noah said:
“My Lord, I seek refuge in You from asking You about that of which I have no knowledge. Unless You forgive me and have mercy upon me, I will be among the losers.”
Abraham, Allah’s close friend, peace be upon him, said:
“Our Lord, forgive me, my parents, and the believers on the Day the Reckoning takes place.”
He also said:
“And who, I hope, will forgive me my sin on the Day of Judgment.”
Moses said:
“You are our Protector, so forgive us and have mercy upon us. You are the best of those who forgive. And ordain good for us in this world and in the Hereafter. Indeed, we have turned to You in repentance.”
He also said:
“My Lord, I have wronged myself, so forgive me.”
And:
“When he regained consciousness, he said, ‘Glory be to You! I repent to You, and I am the first of the believers.’”
Allah Most High says of David:
“He sought his Lord’s forgiveness, fell down bowing, and turned to Him in repentance. So We forgave him that. Indeed, he has nearness to Us and a good place of return.”
Allah Most High relates that Solomon said:
“Forgive me and grant me a kingdom that will belong to no one after me. Indeed, You are the Bestower.”
As for Joseph, the utterly truthful, Allah mentions no sin on his part. Accordingly, He does not mention him seeking forgiveness as would be appropriate following a sin. Rather, He says:
“Thus did We turn evil and indecency away from him. Indeed, he was one of Our chosen servants.”
He thus states that He turned evil and indecency away from Joseph. This indicates that no evil or indecency proceeded from him.
As for His words:
“She certainly desired him, and he felt an inclination toward her, which he would have acted on had he not seen the proof of his Lord.”