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.
Reference: Sunan Abi Dawud 477 In-book : Book 2, Hadith 87 English translation : Book 2, Hadith 477
Help us gift a modern, ad-free Islamic application for the Muslim Ummah. Your donation will be recorded as Sadaqah Jariyah in your book of deeds, In Sha Allah.