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

The Messenger of Allah (ﷺ) said: "Whoever enters this mosque and spits in it, or clears his throat and ejects phlegm, let him dig a hole and bury it. If he does not do that, let him spit into his garment and then go out with it.">