Fix attribute name output when containing invalid characters.