حَدَّثَنَا مُحَمَّدُ بْنُ الْمُثَنَّى، وَزُهَيْرُ بْنُ حَرْبٍ، قَالاَ حَدَّثَنَا يَحْيَى، - وَهُوَ الْقَطَّانُ - عَنْ عُبَيْدِ اللَّهِ، قَالَ أَخْبَرَنِي نَافِعٌ، عَنِ ابْنِ عُمَرَ، أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم قَالَ فِي غَزْوَةِ خَيْبَرَ ‏"‏ مَنْ أَكَلَ مِنْ هَذِهِ الشَّجَرَةِ - يَعْنِي الثُّومَ - فَلاَ يَأْتِيَنَّ الْمَسَاجِدَ ‏"‏ ‏.‏ قَالَ زُهَيْرٌ فِي غَزْوَةٍ ‏.‏ وَلَمْ يَذْكُرْ خَيْبَرَ ‏.‏
Translation
Jabir reported

The Messenger of Allah (ﷺ) forbade eating of onions and leek. When we were overpowered by a desire (to eat) we ate them. Upon this he (the Holy Prophet) said: He who eats of this offensive plant must not approach our mosque, for the angels are harmed by the same things as men.