An ostomy system for receiving bodily waste comprises a drainage bag (200) and a filter (100) comprising an open-cell foam (102) for preventing liquid and solid particles from passing from the drainage bag to its surroundings. The foam defines a passageway for releasing flatus gasses from the drainage bag to its surroundings, and at least a portion of the foam is arranged at a folding line defined by the drainage bag during use thereof. The foam may be a open-cell foam (102) embedded in a closed-cell foam (128) in a filter flange 146. A gas permeable hydrophobic membrane (127) may be provided at an outlet of the open-cell foam (102). The surroundings of the drainage bag (200) may be constituted by the interior of an outer bag.