Updating 5xx-filter.c with production code from locke.wikimedia.org

Change-Id: I8884f755eba87dd5e71bb056205a903b0536181b