The worshipper’s body and clothes should be clean, so that the angels will not be offended by him and neither will his fellow-worshippers.
Hence we are strongly urged to do ghusl, use the siwaak and put on perfume on Fridays, because people are crowded together. Similarly the Muslim who has eaten onions, garlic or anything else with an unpleasant odour is forbidden to attend the mosque, lest he annoy anyone with his smell.
Ahmad (16445) narrated that the Prophet (peace and blessings of Allaah be upon him) said: “It is the duty of every Muslim to do ghusl on Friday, and to use the siwaak and put on perfume, if his family has any.” This hadeeth was classed as saheeh by Shu’ayb al-Arna’oot in his commentary on al-Musnad.
Muslim (564) narrated from Jaabir ibn ‘Abd-Allaah (may Allaah be pleased with him) that the Prophet (peace and blessings of Allaah be upon him) said: “Whoever eats onions, garlic or leeks, let him not approach our mosque, for the angels are annoyed by the same things that annoy the sons of Adam.”
If the socks have an offensive odour, then he should certainly take them off and wash his feet. It is not permissible for him to annoy the angels and other worshippers with their smell. If he enters the mosque like that, he should be told to leave.
Muslim (567) also narrated that ‘Umar ibn al-Khattaab (may Allaah be pleased with him) said: “O people, you eat two plants which I think are nothing but bad: this onion and garlic. I saw the Messenger of Allaah (peace and blessings of Allaah be upon him), if he noticed their smell on a man in the mosque, ordering that he be taken out to al-Baqee’. Whoever eats them, let him cook them to death.”
This shows that the one who smells of garlic and onions, or anything similar, should be expelled from the mosque, and the evil should be removed by hand whenever possible.