كتاب الْمَسَاجِدِ وَمَوَاضِعِ الصَّلاَةِ
5  
The Book of Mosques and Places of Prayer
(17)
Chapter: 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
(17)
باب نَهْىِ مَنْ أَكَلَ ثُومًا أَوْ بَصَلاً أَوْ كُرَّاثًا أَوْ نَحْوَهَا عَنْ حُضُورِ الْمَسْجِدِ ‏‏
Sahih Muslim 564 d

Ibn Juraij has narrated it with the same chain of transmitters:

He who eats of this plant, i. e. garlic, should not come to us in our mosque, and he made no mention of onions or leek.
وَحَدَّثَنَا إِسْحَاقُ بْنُ إِبْرَاهِيمَ، أَخْبَرَنَا مُحَمَّدُ بْنُ بَكْرٍ، ح قَالَ وَحَدَّثَنِي مُحَمَّدُ بْنُ رَافِعٍ، حَدَّثَنَا عَبْدُ الرَّزَّاقِ، قَالاَ جَمِيعًا أَخْبَرَنَا ابْنُ جُرَيْجٍ، بِهَذَا الإِسْنَادِ ‏ "‏ مَنْ أَكَلَ مِنْ هَذِهِ الشَّجَرَةِ - يُرِيدُ الثُّومَ - فَلاَ يَغْشَنَا فِي مَسْجِدِنَا ‏"‏ ‏.‏ وَلَمْ يَذْكُرِ الْبَصَلَ وَالْكُرَّاثَ ‏.‏
Reference : Sahih Muslim 564d
In-book reference : Book 5, Hadith 93
USC-MSA web (English) reference : Book 4, Hadith 1148
  (deprecated numbering scheme)