The problem is probably not the foam - but oil, either applied to the guns surface or leeching out and attacking the foam which then reacts with the guns finish.
Also there are many different coatings, all of which will react differently eg. traditional blue, paint, anodising, parkerising or the early Umarex 'blue' (not sure what that was) and also some oils are more aggressive than others (hydrocarbon based ones being the worst I would suspect).
A soft tissue liner would help here by preventing the gun coming into direct contact with the foam.