Hadithcore
Hadith #2102640

Narrated Abu Sa'id (RA):

Allah's Messenger (ﷺ) said: "When any of you comes to the mosque he should look and if he sees impurity on his sandals (shoes) he should wipe them and then pray in them." [Reported by Abu Dawud, and Ibn Khuzaimah graded it Sahih (authentic)].

وَعَنْ أَبِي سَعِيدٍ ‏- رضى الله عنه ‏- قَالَ : قَالَ رَسُولُ اَللَّهِ ‏- صلى الله عليه وسلم ‏-{ إِذَا جَاءَ أَحَدُكُمْ اَلْمَسْجِدَ , فَلْيَنْظُرْ, فَإِنْ رَأَى فِي نَعْلَيْهِ أَذًى أَوْ قَذَرًا فَلْيَمْسَحْهُ , وَلْيُصَلِّ فِيهِمَا } أَخْرَجَهُ أَبُو دَاوُدَ , وَصَحَّحَهُ اِبْنُ خُزَيْمَةَ [1]‏

References2 variants
Sunnah.com reference
Book 2, Hadith 82
Arabic/English book reference
Book 2, Hadith 216