Sunan Abi Dawud, Hadith 477

Abu Hurairah reported: The Messenger of Allah said: if anyone enters the mosque, and spits in it, or ejects phlegm, he should remove some earth and bury it there. If he does not do so, then he should spit in his clothes and not come out with it.

حَدَّثَنَا الْقَعْنَبِيُّ، حَدَّثَنَا أَبُو مَوْدُودٍ، عَنْ عَبْدِ الرَّحْمَنِ بْنِ أَبِي حَدْرَدٍ الأَسْلَمِيِّ، سَمِعْتُ أَبَا هُرَيْرَةَ، يَقُولُ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏ "‏ مَنْ دَخَلَ هَذَا الْمَسْجِدَ فَبَزَقَ فِيهِ أَوْ تَنَخَّمَ فَلْيَحْفِرْ فَلْيَدْفِنْهُ فَإِنْ لَمْ يَفْعَلْ فَلْيَبْزُقْ فِي ثَوْبِهِ ثُمَّ لْيَخْرُجْ بِهِ ‏" ‏ ‏.‏

sunnah.com