Sahih Muslim 561
Sahih Muslim · Book 5: The Book of Mosques and Places of Prayer · Prohibiting one who has eaten garlic, onions, or leeks, and other things that have an offensive odor from coming to the masjid, until that smell has gone away, and such a person should be expelled from the masjid
Ibn 'Umar reported:
حَدَّثَنَا أَبُو بَكْرِ بْنُ أَبِي شَيْبَةَ ، حَدَّثَنَا ابْنُ نُمَيْرٍ ، ح قَالَ وَحَدَّثَنَا مُحَمَّدُ بْنُ عَبْدِ اللَّهِ بْنِ نُمَيْرٍ ، - وَاللَّفْظُ لَهُ - حَدَّثَنَا أَبِي قَالَ، حَدَّثَنَا عُبَيْدُ اللَّهِ ، عَنْ نَافِعٍ ، عَنِ ابْنِ عُمَرَ ، أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم قَالَ " مَنْ أَكَلَ مِنْ هَذِهِ الْبَقْلَةِ فَلاَ يَقْرَبَنَّ مَسَاجِدَنَا حَتَّى يَذْهَبَ رِيحُهَا " . يَعْنِي الثُّومَ .
The Messenger of Allah (ﷺ) said: He who eats of this (offensive) plant must not approach our mosque, till its odor dies: (plant signifies) garlic.